Beispiel #1
0
        public static bool ImportSpssAll(StudyUnitVM studyUnit, MainWindowVM mainWindow)
        {
            string path = IOUtils.QueryOpenPathName(SPSS_FILTER);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            try
            {
                SpssReader reader = new SpssReader();
                if (!reader.ImportVariables(path, studyUnit))
                {
                    return(false);
                }
                StudyUnit studyUnitModel = studyUnit.StudyUnitModel;
                mainWindow.RecreateViewModels();
                RawData rawData = reader.LoadRawData(path);
                if (rawData == null)
                {
                    return(false);
                }

                StudyUnitVM           newStudyUnit    = mainWindow.GetStudyUnit(studyUnitModel);
                List <StatisticsInfo> statisticsInfos = StatisticsUtils.CreateStatisticsInfos(rawData, newStudyUnit);
                studyUnitModel.StatisticsInfos = statisticsInfos;
                mainWindow.RecreateViewModels();
                return(true);
            }
            catch (Exception ex)
            {
                EDOUtils.ShowUnexpectedError(ex);
            }
            return(false);
        }
Beispiel #2
0
        public SamplingFormVM(StudyUnitVM studyUnit)
            : base(studyUnit)
        {
            samplings = new ObservableCollection <SamplingVM>();

            //change how to name the title
            //*Find the unique title like unsed
            //*The title such as Concept and Amount can be changed manually,
            //Cannot do here
            HashSet <string> titles = Sampling.CollectTitles(studyUnit.SamplingModels);

            foreach (Sampling samplingModel in studyUnit.SamplingModels)
            {
                int        uniqIndex = EDOUtils.UniqOrderNo(titles, samplingModel.Title, PREFIX);
                SamplingVM sampling  = new SamplingVM(samplingModel)
                {
                    Parent      = this,
                    OrderNo     = uniqIndex,
                    OrderPrefix = PREFIX
                };
                sampling.Init();
                samplings.Add(sampling);
                titles.Add(sampling.Title); //Add in title set.
            }
            modelSyncher = new ModelSyncher <SamplingVM, Sampling>(this, samplings, studyUnit.SamplingModels);
        }
Beispiel #3
0
 public SelectResponseWindowVM(StudyUnitVM studyUnit, ResponseVM excludeResponse)
     : base(studyUnit)
 {
     this.excludeResponse = excludeResponse;
     this.responses       = new ObservableCollection <ResponseVM>();
     Filter("");
 }
Beispiel #4
0
        public static void ExportQuestionnaire(EDOConfig config, StudyUnitVM studyUnit)
        {
            ControlConstructSchemeVM controlConstructScheme = null;

            if (studyUnit.ControlConstructSchemes.Count > 1)
            {
                SelectObjectWindowVM <ControlConstructSchemeVM> vm = new SelectObjectWindowVM <ControlConstructSchemeVM>(studyUnit.ControlConstructSchemes);
                SelectObjectWindow window = new SelectObjectWindow(vm);
                controlConstructScheme = SelectObjectWindow.Select(Resources.SelectOrder, vm) as ControlConstructSchemeVM; //Select Sequence
            }
            else if (studyUnit.ControlConstructSchemes.Count == 1)
            {
                controlConstructScheme = studyUnit.ControlConstructSchemes[0];
            }
            if (controlConstructScheme == null)
            {
                return;
            }
            string path = IOUtils.QuerySavePathName(Resources.ExportQuestionnair + ": " + controlConstructScheme.Title, null, QUESTIONNAIRE_FILTER, true);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            try
            {
                QuestionnaireWriter writer = new QuestionnaireWriter(config, controlConstructScheme);
                writer.Write(path);
            }
            catch (Exception ex)
            {
                EDOUtils.ShowUnexpectedError(ex);
            }
        }
Beispiel #5
0
 public SelectVariableWindowVM(StudyUnitVM studyUnit)
     : base(studyUnit)
 {
     variables         = new ObservableCollection <VariableVM>();
     selectedVariables = new ObservableCollection <VariableVM>();
     Filter("");
 }
Beispiel #6
0
        public static void ExportSetupSyntax(StudyUnitVM studyUnit)
        {
            DataFileVM dataFile = null;

            if (studyUnit.DataFiles.Count > 1)
            {
                SelectObjectWindowVM <DataFileVM> vm = new SelectObjectWindowVM <DataFileVM>(studyUnit.DataFiles);
                SelectObjectWindow window            = new SelectObjectWindow(vm);
                dataFile = SelectObjectWindow.Select(Resources.SelectDataFile, vm) as DataFileVM; //Select Data File
            }
            else if (studyUnit.DataFiles.Count == 1)
            {
                dataFile = studyUnit.DataFiles[0];
            }
            if (dataFile == null)
            {
                return;
            }
            string path = IOUtils.QuerySavePathName(Resources.ExportSetupSyntax, null, SETUPSYNTAX_FILTER, true); //Export Setup Syntax

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            try
            {
                SetupSyntaxWriter writer = new SetupSyntaxWriter(studyUnit, dataFile);
                writer.Write(path);
            }
            catch (Exception ex)
            {
                EDOUtils.ShowUnexpectedError(ex);
            }
        }
Beispiel #7
0
        public MemberFormVM(StudyUnitVM studyUnit) : base(studyUnit)
        {
            members       = new ObservableCollection <MemberVM>();
            organizations = new ObservableCollection <OrganizationVM>();

            //Create the list of OrganizationVM(showed at the bottom of the window and used by Organization of Members combo)
            int i = 1;

            foreach (Organization organizationModel in studyUnit.OrganizationModels)
            {
                OrganizationVM organization = new OrganizationVM(organizationModel);
                InitExistOrganization(organization, i++);
                organizations.Add(organization);
            }

            //Create MemberVM list
            i = 1;
            foreach (Member memberModel in studyUnit.MemberModels)
            {
                OrganizationVM organization = OrganizationVM.Find(organizations, memberModel.OrganizationId);
                MemberVM       member       = new MemberVM(memberModel, organization.OrganizationName);
                InitExistMember(member, i++);
                members.Add(member);
            }
            memberSyncher       = new ModelSyncher <MemberVM, Member>(this, members, studyUnit.MemberModels);
            organizationSyncher = new ModelSyncher <OrganizationVM, Organization>(this, organizations, studyUnit.OrganizationModels);
        }
Beispiel #8
0
        public AbstractFormVM(StudyUnitVM studyUnit) : base(studyUnit)
        {
            abstractModel           = studyUnit.AbstractModel;
            this.IsIgnoreValidation = true;

            books = new ObservableCollection <BookVM>();
        }
Beispiel #9
0
        private DataGridComboBoxColumn CreateStudyUnitColumn(StudyUnitVM studyUnit, int index)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("<DataGridComboBoxColumn ");
            sb.Append("xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' ");
            sb.Append("xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' ");
            sb.Append("Header='").Append(studyUnit.Title).Append("' Width='100'>");
            sb.Append("<DataGridComboBoxColumn.ElementStyle>");
            sb.Append("<Style TargetType='ComboBox'>");
            sb.Append("<Setter Property='ItemsSource' Value='{Binding Path=DiffOptions}'/>");
            sb.Append("<Setter Property='DisplayMemberPath' Value='DetailLabel'/>");
            sb.Append("<Setter Property='SelectedItem' Value='{Binding SelectedDiffOptions[" + index + "]}'/>");
            sb.Append("</Style>");
            sb.Append("</DataGridComboBoxColumn.ElementStyle>");
            sb.Append("<DataGridComboBoxColumn.EditingElementStyle>");
            sb.Append("<Style TargetType='ComboBox'>");
            sb.Append("<Setter Property='ItemsSource' Value='{Binding Path=DiffOptions}'/>");
            sb.Append("<Setter Property='DisplayMemberPath' Value='DetailLabel'/>");
            sb.Append("<Setter Property='SelectedItem' Value='{Binding SelectedDiffOptions[" + index + "]}'/>");
            sb.Append("</Style>");
            sb.Append("</DataGridComboBoxColumn.EditingElementStyle>");
            sb.Append("</DataGridComboBoxColumn>");
            return((DataGridComboBoxColumn)XamlReader.Parse(sb.ToString()));
        }
Beispiel #10
0
 private static bool SaveStudyUnit(StudyUnitVM studyUnit, bool queryPathName, List <string> usingPaths)
 {
     if (!QuerySavePathNamesUniq(studyUnit, STUDYUNIT_FILTER, queryPathName, usingPaths))
     {
         return(false);
     }
     EDOSerializer.DoSave <StudyUnit>(studyUnit.StudyUnitModel);
     return(true);
 }
Beispiel #11
0
 public CodeFormVM(StudyUnitVM studyUnit) : base(studyUnit)
 {
     codeSchemes = new ObservableCollection <CodeSchemeVM>();
     foreach (CodeScheme codeSchemeModel in studyUnit.CodeSchemeModels)
     {
         CodeSchemeVM codeScheme = CreateCodeScheme(codeSchemeModel);
         codeSchemes.Add(codeScheme);
     }
     modelSyncher = new ModelSyncher <CodeSchemeVM, CodeScheme>(this, codeSchemes, studyUnit.CodeSchemeModels);
 }
Beispiel #12
0
        public static StudyUnit LoadStudyUnitInGroup(List <StudyUnitVM> otherStudyUnits)
        {
            List <string> usingPathNames = StudyUnitVM.GetAllPathNames(otherStudyUnits);
            string        pathName       = QueryOpenPathNameUniq(STUDYUNIT_FILTER, usingPathNames);

            if (string.IsNullOrEmpty(pathName))
            {
                return(null);
            }
            return(Load <StudyUnit>(pathName));
        }
Beispiel #13
0
        public static bool SaveStudyUnit(StudyUnitVM studyUnit, bool queryPathName, List <StudyUnitVM> otherStudyUnits)
        {
            List <string> usingPathNames = StudyUnitVM.GetAllPathNames(otherStudyUnits);

            if (!QuerySavePathNamesUniq(studyUnit, STUDYUNIT_FILTER, queryPathName, usingPathNames))
            {
                return(false);
            }
            EDOSerializer.DoSave <StudyUnit>(studyUnit.StudyUnitModel);
            return(true);
        }
Beispiel #14
0
 public CategoryFormVM(StudyUnitVM studyUnit) : base(studyUnit)
 {
     categorySchemes = new ObservableCollection <CategorySchemeVM>();
     foreach (CategoryScheme categorySchemeModel in studyUnit.CategorySchemeModels)
     {
         CategorySchemeVM categoryScheme = new CategorySchemeVM(categorySchemeModel)
         {
             Parent = this
         };
         categorySchemes.Add(categoryScheme);
     }
     modelSyncher = new ModelSyncher <CategorySchemeVM, CategoryScheme>(this, categorySchemes, studyUnit.CategorySchemeModels);
 }
Beispiel #15
0
 public DataFileFormVM(StudyUnitVM studyUnit) : base(studyUnit)
 {
     dataFiles = new ObservableCollection <DataFileVM>();
     foreach (DataFile dataFileModel in studyUnit.DataFileModels)
     {
         DataSetVM dataSet = studyUnit.FindDataSet(dataFileModel.DataSetId);
         if (dataSet != null)
         {
             DataFileVM dataFile = createDataFile(dataFileModel, dataSet);
             dataFiles.Add(dataFile);
         }
     }
     modelSyncher = new ModelSyncher <DataFileVM, DataFile>(this, dataFiles, studyUnit.DataFileModels);
 }
Beispiel #16
0
 public BookFormVM(StudyUnitVM studyUnit)
     : base(studyUnit)
 {
     books = new ObservableCollection <BookVM>();
     foreach (Book bookModel in studyUnit.BookModels)
     {
         BookVM book = new BookVM(bookModel)
         {
             Parent = this
         };
         books.Add(book);
     }
     modelSyncher = new ModelSyncher <BookVM, Book>(this, books, studyUnit.BookModels);
 }
Beispiel #17
0
        public void Filter(string text)
        {
            StudyUnitVM studyUnit = (StudyUnitVM)this.Parent;
            string      lowerText = text.ToLower();

            categories.Clear();
            foreach (CategoryVM category in studyUnit.CategoryForm.AllCategories)
            {
                if (string.IsNullOrEmpty(lowerText) || category.Title.ToLower().Contains(lowerText))
                {
                    categories.Add(category);
                }
            }
        }
Beispiel #18
0
        public static bool ImportData(StudyUnitVM studyUnit)
        {
            string path = IOUtils.QueryOpenPathName(Resources.DataFilter);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            bool result = false;

            try
            {
                Mouse.OverrideCursor = Cursors.Wait;

                string  extension = Path.GetExtension(path);
                RawData rawData   = null;
                if (extension == ".sav")
                {
                    SpssReader reader = new SpssReader();
                    rawData = reader.LoadRawData(path);
                }
                else if (extension == ".xlsx")
                {
                    ExcelReader reader = new ExcelReader();
                    rawData = reader.LoadRawData(path);
                }
                else if (extension == ".csv")
                {
                    CsvReader reader = new CsvReader();
                    rawData = reader.LoadRawData(path);
                }


                if (rawData != null)
                {
                    List <StatisticsInfo> statisticsInfos = StatisticsUtils.CreateStatisticsInfos(rawData, studyUnit);
                    studyUnit.StudyUnitModel.StatisticsInfos = statisticsInfos;
                    result = true;
                }
            }
            catch (Exception ex)
            {
                EDOUtils.ShowUnexpectedError(ex);
            }
            finally
            {
                Mouse.OverrideCursor = null;
            }
            return(result);
        }
Beispiel #19
0
        public void Filter(string text)
        {
            StudyUnitVM studyUnit = (StudyUnitVM)this.Parent;

            string lowerText = text.ToLower();

            members.Clear();
            foreach (MemberVM member in studyUnit.MemberForm.Members)
            {
                if (string.IsNullOrEmpty(lowerText) || member.FullName.ToLower().Contains(lowerText))
                {
                    members.Add(member);
                }
            }
        }
Beispiel #20
0
 public VariableFormVM(StudyUnitVM studyUnit) : base(studyUnit)
 {
     variables = new ObservableCollection <VariableVM>();
     foreach (Variable variableModel in studyUnit.VariableModels)
     {
         //Create VariableVM
         VariableVM variable = new VariableVM(variableModel);
         InitVariable(variable);
         //Create ResponseVM
         variable.Response = CreateResponse(variableModel.Response);
         //Add to array
         variables.Add(variable);
     }
     modelSyncher = new ModelSyncher <VariableVM, Variable>(this, variables, studyUnit.VariableModels);
 }
Beispiel #21
0
        public void Filter(string text)
        {
            StudyUnitVM studyUnit = (StudyUnitVM)this.Parent;

            string lowerText = text.ToLower();

            variables.Clear();
            foreach (VariableVM variable in studyUnit.VariableForm.Variables)
            {
                if (string.IsNullOrEmpty(lowerText) || variable.Title.ToLower().Contains(lowerText))
                {
                    variables.Add(variable);
                }
            }
        }
Beispiel #22
0
        public QuestionGroupFormVM(StudyUnitVM studyUnit)
            : base(studyUnit)
        {
            ObservableCollection <QuestionVM> allQuestions = studyUnit.AllQuestions;

            questionGroups = new ObservableCollection <QuestionGroupVM>();
            foreach (QuestionGroup questionGroupModel in studyUnit.QuestionGroupModels)
            {
                QuestionGroupVM questionGroup = new QuestionGroupVM(questionGroupModel, allQuestions)
                {
                    Parent = this
                };
                questionGroups.Add(questionGroup);
            }
            modelSyncher = new ModelSyncher <QuestionGroupVM, QuestionGroup>(this, questionGroups, studyUnit.QuestionGroupModels);
        }
Beispiel #23
0
//        public string Method
//        {
//            //Make in use of Codebook output
//            get
//            {
//                return Option.FindLabel(samplingMethods, MethodCode);
//            }
//       }

        public void GenerateCollector()
        {
            StudyUnitVM  studyUnit  = StudyUnit;
            MemberFormVM memberForm = studyUnit.MemberForm;

            if (IsCollectorTypeIndividual)
            {
                MemberVM newMember = memberForm.AppendMember(sampling.MemberId, this.LastName, this.FirstName, this.OrganizationName, this.Position);
                UpdateIndividual(newMember);
            }
            else
            {
                OrganizationVM organization = memberForm.AppendOrganization(sampling.MemberId, this.OrganizationName);
                UpdateOrganization(organization);
            }
        }
Beispiel #24
0
 public QuestionFormVM(StudyUnitVM studyUnit)
     : base(studyUnit)
 {
     concepts      = new ObservableCollection <ConceptVM>();
     questionsDict = new Dictionary <string, ObservableCollection <QuestionVM> >();
     foreach (Question questionModel in studyUnit.QuestionModels)
     {
         //Create QuestionVM
         ObservableCollection <QuestionVM> questions = RelatedQuestions(questionModel.ConceptId);
         QuestionVM question = new QuestionVM(questionModel);
         InitQuestion(question);
         //Create ResponseVM
         question.Response = CreateResponse(questionModel.Response);
         //Add to array
         questions.Add(question);
     }
 }
Beispiel #25
0
        public EventFormVM(StudyUnitVM studyUnit) : base(studyUnit)
        {
            events = new ObservableCollection <EventVM>();
            foreach (Event eventModel in studyUnit.EventModels)
            {
                EventVM ev = new EventVM(eventModel);
                InitEvent(ev);
                events.Add(ev);
            }
            modelSyncher = new ModelSyncher <EventVM, Event>(this, events, studyUnit.EventModels);

            contents = new ObservableCollection <string>();
            foreach (Option option in Options.EventTypes)
            {
                contents.Add(option.Label);
            }
        }
Beispiel #26
0
        private static readonly string PREFIX = Resources.FundMoney; //Amount

        public FundingInfoFormVM(StudyUnitVM studyUnitVM) : base(studyUnitVM)
        {
            fundingInfos = new ObservableCollection <FundingInfoVM>();
            int i = 1;

            foreach (FundingInfo fundingInfoModel in studyUnitVM.FundingInfoModels)
            {
                FundingInfoVM fundingInfo = new FundingInfoVM(fundingInfoModel)
                {
                    Parent      = this,
                    OrderNo     = i++,
                    OrderPrefix = PREFIX
                };
                fundingInfo.InitTitle();
                fundingInfos.Add(fundingInfo);
            }
            modelSyncher = new ModelSyncher <FundingInfoVM, FundingInfo>(this, fundingInfos, studyUnitVM.FundingInfoModels);
        }
Beispiel #27
0
        public static void ExportCodebook(StudyUnitVM studyUnit)
        {
            string path = IOUtils.QuerySavePathName(Resources.ExportCodebook, null, CODEBOOK_FILTER, true); //Export Codebook

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            try
            {
                CodebookWriter writer = new CodebookWriter(studyUnit);
                writer.Write(path);
            }
            catch (Exception ex)
            {
                EDOUtils.ShowUnexpectedError(ex);
            }
        }
Beispiel #28
0
        public void Filter(string text)
        {
            StudyUnitVM studyUnit = (StudyUnitVM)Parent;

            string lowerText = text.ToLower();

            responses.Clear();
            foreach (ResponseVM response in studyUnit.QuestionForm.AllResponses)
            {
                if (response == excludeResponse)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(lowerText) || response.Title.ToLower().Contains(lowerText))
                {
                    responses.Add(response);
                }
            }
        }
Beispiel #29
0
        public ConceptFormVM(StudyUnitVM studyUnit) : base(studyUnit)
        {
            this.conceptSchemes = new ObservableCollection <ConceptSchemeVM>();
            int i = 1;

            foreach (ConceptScheme conceptSchemeModel in studyUnit.ConceptSchemeModels)
            {
                ConceptSchemeVM conceptScheme = new ConceptSchemeVM(conceptSchemeModel)
                {
                    Parent      = this,
                    OrderNo     = i++,
                    OrderPrefix = PREFIX
                };
                conceptScheme.InitTitle();
                conceptSchemes.Add(conceptScheme);
            }
            modelSyncher = new ModelSyncher <ConceptSchemeVM, ConceptScheme>(this, conceptSchemes, studyUnit.ConceptSchemeModels);
            allConcepts  = new ObservableCollection <ConceptVM>();
        }
Beispiel #30
0
        public static bool ImportSpssVariables(StudyUnitVM studyUnit)
        {
            string path = IOUtils.QueryOpenPathName(SPSS_FILTER);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }
            try
            {
                SpssReader reader = new SpssReader();
                return(reader.ImportVariables(path, studyUnit));
            }
            catch (Exception ex)
            {
                EDOUtils.ShowUnexpectedError(ex);
            }
            return(false);
        }