public static VariableEditorViewModel GetModelFromFile(ManagedFile file) { var logger = LogManager.GetLogger("FileToVariableEditorMapper"); logger.Debug("Entering GetModelFromFile()"); var model = new VariableEditorViewModel(file); // Get the DDI PhysicalInstance that corresponds to this ManagedFile. logger.Debug("Getting PhysicalInstance"); var physicalInstance = GetPhysicalInstance(file, file.CatalogRecord.Organization.AgencyID); logger.Debug("Got PhysicalInstance"); // Make the list of variables. if (physicalInstance == null) { logger.Debug("Got null PhysicalInstance"); return(model); } // Populate what is needed to get the list of variables. logger.Debug("Populating PhysicalInstance"); var client = RepositoryHelper.GetClient(); foreach (var dr in physicalInstance.DataRelationships) { client.PopulateItem(dr, false, Algenta.Colectica.Model.Repository.ChildReferenceProcessing.PopulateLatest); } logger.Debug("Populated PhysicalInstance"); var allVariables = physicalInstance.DataRelationships .SelectMany(x => x.LogicalRecords) .SelectMany(x => x.VariablesInRecord); foreach (var variable in allVariables) { var variableModel = new VariableModel() { Id = variable.Identifier.ToString(), Agency = variable.AgencyId, Name = variable.ItemName.Current, Label = variable.Label.Current, Version = variable.Version, LastUpdated = variable.VersionDate.ToShortDateString() }; model.Variables.Add(variableModel); } model.VariablesJson = Newtonsoft.Json.JsonConvert.SerializeObject(model.Variables, Newtonsoft.Json.Formatting.None); model.IsUserCurator = false; model.IsUserApprover = false; logger.Debug("Leaving GetModelFromFile()"); return(model); }
/// <summary> /// Открывает Редактор переменных /// </summary> public async Task OpenVariableEditor( VariablesRepository repository, IVariableWrapper variable = null, WindowType hostIdentifier = WindowType.Root) { var viewModel = new VariableEditorViewModel(_dataProvider, variable); var view = new VariableEditor { ViewModel = viewModel }; await DialogHost.Show(view, Common.GetEnumDescription(hostIdentifier)); }