Example #1
0
		public MachineStationsVM(MachineVM machine, AccessType access)
			: base(access)
		{
            UnitOfWork = new SoheilEdmContext();
			CurrentMachine = machine;
            MachineDataService = new MachineDataService(UnitOfWork);
			MachineDataService.StationAdded += OnStationAdded;
			MachineDataService.StationRemoved += OnStationRemoved;
            StationDataService = new StationDataService(UnitOfWork);

			var selectedVms = new ObservableCollection<StationMachineVM>();
			foreach (var stationMachine in MachineDataService.GetStations(machine.Id))
			{
				selectedVms.Add(new StationMachineVM(stationMachine, Access, StationMachineDataService, RelationDirection.Reverse));
			}
			SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<StationVM>();
            foreach (var station in StationDataService.GetActives(SoheilEntityType.Machines, CurrentMachine.Id))
            {
                allVms.Add(new StationVM(station, Access, StationDataService));
            }
            AllItems = new ListCollectionView(allVms);

			IncludeCommand = new Command(Include, CanInclude);
			ExcludeCommand = new Command(Exclude, CanExclude);
		}
Example #2
0
        private void InitializeData()
        {
            UnitOfWork = new SoheilEdmContext();
            StationDataService = new StationDataService(UnitOfWork);
            StationDataService.StationAdded += OnStationAdded;

            ColumnHeaders = new List<ColumnInfo> 
            { 
                new ColumnInfo("Code",0), 
                new ColumnInfo("Name",1), 
                new ColumnInfo("Index","txtStationIndex",2), 
                new ColumnInfo("Status",3) ,
                new ColumnInfo("Mode",4,true) 
            };

            AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems);
            AddGroupCommand = new Command(Add, CanAddGroup);
            CreateItems(null);
        }
Example #3
0
        public StationMachinesVM(StationVM station, AccessType access):base(access)
        {
            UnitOfWork = new SoheilEdmContext();
            CurrentStation = station;
            StationDataService = new StationDataService(UnitOfWork);
            StationDataService.MachineAdded += OnMachineAdded;
            StationDataService.MachineRemoved += OnMachineRemoved;
            MachineDataService = new MachineDataService(UnitOfWork);
            StationMachineDataService = new StationMachineDataService(UnitOfWork);
            MachineFamilyDataService = new MachineFamilyDataService(UnitOfWork);

            var selectedVms = new ObservableCollection<StationMachineVM>();
            foreach (var stationMachine in StationDataService.GetMachines(station.Id))
            {
                selectedVms.Add(new StationMachineVM(stationMachine, Access, StationMachineDataService, RelationDirection.Straight));
            }
            SelectedItems = new ListCollectionView(selectedVms);

            var allVms = new ObservableCollection<MachineVM>();
            foreach (var machine in MachineDataService.GetActives()
				.Where(machine => !selectedVms.Any(stationMachine => stationMachine.MachineId == machine.Id)))
            {
                allVms.Add(new MachineVM(machine, Access, MachineDataService, MachineFamilyDataService));
            }
            AllItems = new ListCollectionView(allVms);

            IncludeCommand = new Command(Include, CanInclude);
            ExcludeCommand = new Command(Exclude, CanExclude);
			IncludeAllCommand = new Command(o =>
			{
				foreach (var vm in allVms.ToArray())
				{
					StationDataService.AddMachine(CurrentStation.Id, ((IEntityItem)vm).Id);
				}
			}, () => allVms.Any());
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductVM"/> class from the model.
 /// </summary>
 /// <param name="entity">The model.</param>
 /// <param name="access"></param>
 public StationVM(Station entity, AccessType access, StationDataService dataService)
     : base(access)
 {
     InitializeData(dataService);
     _model = entity;
 }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ProductGroupVM"/> class initialized with default values.
 /// </summary>
 public StationVM(AccessType access, StationDataService dataService):base(access)
 {
     InitializeData(dataService);
 }
Example #6
0
 public static Station CreateNew(StationDataService dataService)
 {
     int id = dataService.AddModel(new Station { Name = "جدید", Code = string.Empty, Index = dataService.GetNextIndex(), CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now, Status = (byte)Status.Active});
     return dataService.GetSingle(id);
 }
Example #7
0
 private void InitializeData(StationDataService dataService)
 {
     StationDataService = dataService;
     SaveCommand = new Command(Save, CanSave);
 }
Example #8
0
        private void InitializeData()
        {
            UnitOfWork = new SoheilEdmContext();
            CostCenterDataService = new CostCenterDataService(UnitOfWork);
            MachineDataService = new MachineDataService(UnitOfWork);
            StationDataService = new StationDataService(UnitOfWork);
            OperatorDataService = new OperatorDataService(UnitOfWork);
            ActivityDataService = new ActivityDataService(UnitOfWork);
            WarehouseDataService = new PartWarehouseDataService(UnitOfWork);

            CostDataService = new CostDataService(UnitOfWork);
            CostDataService.CostAdded += OnCostAdded;
            CostCenterDataService.CostCenterAdded += OnCostCenterAdded;

            ColumnHeaders = new List<ColumnInfo> 
            { 
                new ColumnInfo("Description",0), 
                new ColumnInfo("CostType",1,true), 
                new ColumnInfo("SelectedCostSource","txtCostSource",2,true), 
                new ColumnInfo("CostValue","txtCost",3,true),
                new ColumnInfo("Mode",4,true) 
            };

            AddCommand = new Command(Add, CanAdd);RefreshCommand = new Command(CreateItems);
            AddGroupCommand = new Command(AddGroup);
            ViewCommand = new Command(View, CanView);

            var machineViewModels = new ObservableCollection<MachineInfoVM>();
            foreach (var entity in MachineDataService.GetAll())
            {
                machineViewModels.Add(new MachineInfoVM(entity));
            }
            Machines = new ListCollectionView(machineViewModels);
            var operatorViewModels = new ObservableCollection<OperatorInfoVM>();
            foreach (var entity in OperatorDataService.GetAll())
            {
                operatorViewModels.Add(new OperatorInfoVM(entity));
            }
            Operators = new ListCollectionView(operatorViewModels);
            var stationViewModels = new ObservableCollection<StationInfoVM>();
            foreach (var entity in StationDataService.GetAll())
            {
                stationViewModels.Add(new StationInfoVM(entity));
            }
            Stations = new ListCollectionView(stationViewModels);

            var activityViewModels = new ObservableCollection<ActivityInfoVM>();
            foreach (var entity in ActivityDataService.GetAll())
            {
                activityViewModels.Add(new ActivityInfoVM(entity));
            }
            Activities = new ListCollectionView(activityViewModels);

            var warehouseViewModels = new ObservableCollection<PartWarehouseInfoVM>();
            foreach (var entity in WarehouseDataService.GetAll())
            {
                warehouseViewModels.Add(new PartWarehouseInfoVM(entity));
            }
            Warehouses = new ListCollectionView(warehouseViewModels);

            CreateItems(null);
        }