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); }
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); }
public SelectResponseWindowVM(StudyUnitVM studyUnit, ResponseVM excludeResponse) : base(studyUnit) { this.excludeResponse = excludeResponse; this.responses = new ObservableCollection <ResponseVM>(); Filter(""); }
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); } }
public SelectVariableWindowVM(StudyUnitVM studyUnit) : base(studyUnit) { variables = new ObservableCollection <VariableVM>(); selectedVariables = new ObservableCollection <VariableVM>(); Filter(""); }
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); } }
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); }
public AbstractFormVM(StudyUnitVM studyUnit) : base(studyUnit) { abstractModel = studyUnit.AbstractModel; this.IsIgnoreValidation = true; books = new ObservableCollection <BookVM>(); }
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())); }
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); }
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); }
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)); }
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); }
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); }
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); }
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); }
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); } } }
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); }
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); } } }
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); }
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); } } }
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); }
// 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); } }
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); } }
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); } }
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); }
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); } }
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); } } }
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>(); }
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); }