Пример #1
0
 public static IEnumerable <ExcelRuleViewModel> FromModels(IEnumerable <ExcelImportRule> models)
 {
     foreach (var model in models)
     {
         var viewModel = new ExcelRuleViewModel();
         FillViewModel(viewModel, model);
         yield return(viewModel);
     }
 }
Пример #2
0
        private void UpdateRules()
        {
            var items = ImportRulesLocator.GetBehaviors().ToArray();

            Rules.Clear();
            var excels = items.Where(i => i is ExcelImportRule).Cast <ExcelImportRule>();

            foreach (var rule in ExcelRuleViewModel.FromModels(excels))
            {
                Rules.Add(rule);
            }
        }
Пример #3
0
        private static void FillViewModel(ExcelRuleViewModel viewModel, ExcelImportRule model)
        {
            viewModel._model = model;

            viewModel.Identificator  = model.Identificator;
            viewModel.Name           = model.Name;
            viewModel.Description    = model.Description;
            viewModel.RowOffset      = model.RowOffset;
            viewModel.ColumnOffset   = model.ColumnOffset;
            viewModel.UseCsvFile     = model.CsvMode;
            viewModel.WorksheetIndex = model.WorksheetIndex;

            FillFieldViewModel(viewModel.NameField,
                               model.Columns.FirstOrDefault(c => c.Name == viewModel.NameField.Name));

            FillFieldViewModel(viewModel.BrandField,
                               model.Columns.FirstOrDefault(c => c.Name == viewModel.BrandField.Name));

            FillFieldViewModel(viewModel.PartNumberField,
                               model.Columns.FirstOrDefault(c => c.Name == viewModel.PartNumberField.Name));

            FillFieldViewModel(viewModel.PriceField,
                               model.Columns.FirstOrDefault(c => c.Name == viewModel.PriceField.Name));

            FillFieldViewModel(viewModel.BalanceField,
                               model.Columns.FirstOrDefault(c => c.Name == viewModel.BalanceField.Name));

            FillFieldViewModel(viewModel.AnalogsField,
                               model.Columns.FirstOrDefault(c => c.Name == viewModel.AnalogsField.Name));

            /*
             * FillFieldViewModel(viewModel.DistributorField, model.Columns.FirstOrDefault(c => c.Name == viewModel.DistributorField.Name));
             * FillFieldViewModel(viewModel.CommentaryField, model.Columns.FirstOrDefault(c => c.Name == viewModel.CommentaryField.Name)); */

            viewModel.RaisePropertyChanged("Model");
            viewModel.RaisePropertyChanged("IsNew");
        }