예제 #1
0
        public override void Run()
        {
            base.Run();

            var viewService             = Container.Resolve <IViewService>();
            var guaranteeExistViewModel = typeof(BPWorkflowListViewModel);

            foreach (var item in BLHelper.Registered)
            {
                // пытаемся найти ViewModel в стандартном namespace
                var assumeListViewModelName   = string.Format("{0}.{1}ListViewModel", guaranteeExistViewModel.Namespace, item.ObjectType.Name);
                var assumeTreeViewModelName   = string.Format("{0}.{1}TreeViewModel", guaranteeExistViewModel.Namespace, item.ObjectType.Name);
                var assumeObjectViewModelName = string.Format("{0}.{1}ViewModel", guaranteeExistViewModel.Namespace, item.ObjectType.Name);

                // если нет - берем базовый тип
                var listViewModelType = Type.GetType(assumeListViewModelName) ?? typeof(ObjectListViewModelBase <>).MakeGenericType(item.ObjectType);

                // для TreeView если нет - не берем базовый тип
                //var treeViewModelType = Type.GetType(assumeTreeViewModelName) ?? typeof(ObjectTreeViewModelBase<>).MakeGenericType(item.ObjectType);
                var treeViewModelType = Type.GetType(assumeTreeViewModelName);

                // если нет - берем базовый тип
                var objectViewModelType = Type.GetType(assumeObjectViewModelName) ?? typeof(ObjectViewModelBase <>).MakeGenericType(item.ObjectType);

                // регистриуем во viewservice
                viewService.Register(item.ObjectType.Name + ViewServiceRegisterSuffixListShow, listViewModelType);
                if (treeViewModelType != null)
                {
                    viewService.Register(item.ObjectType.Name + ViewServiceRegisterSuffixTreeShow, treeViewModelType);
                }

                // регистрируем в IoC
                var interfaceType = typeof(IListViewModel <>).MakeGenericType(item.ObjectType);
                IoC.Instance.Register(interfaceType, listViewModelType);

                var interfaceObjectType = typeof(IObjectViewModel <>).MakeGenericType(item.ObjectType);
                IoC.Instance.Register(interfaceObjectType, objectViewModelType);
            }

            viewService.Register("ARTMASSINPUT", typeof(ArtMassInputViewModel));
            viewService.Register(StringResources.Packing, typeof(IPackingViewModel));
            //viewService.Register("OPENWCL", typeof(OpenWclViewCommand));
            viewService.Register(StringResources.Chat, typeof(IChatViewModel));
            viewService.Register(MainViewModel.ShowMainMenuAction, typeof(MainMenuTreeViewModel));

            //Включаем кеширование wf
            BPWorkflowManager.SetObjectCachable(BatchcodeWorkflowCodes.ExecuteWorkflowCode);
            foreach (var wf in BatchcodeWorkflowCodes.WorkflowCodes)
            {
                BPWorkflowManager.SetObjectCachable(wf);
            }

            LoadApplicationResource("/wmsMLC.DCL.Content;Component/Themes/Generic.xaml");

            SplashScreenHelper.SetState(StringResources.LoadCustomization);
            MainViewModel.LoadCustomization();
            MainViewModel.ShowTree();
            MainViewModel.LoadDxAssemblies();
        }
예제 #2
0
 internal static void RegisterCachableWorkflow()
 {
     // отмечаем какие workflow можно кэшировать
     foreach (var wf in GetCachableWorkflows())
     {
         BPWorkflowManager.SetObjectCachable(wf);
     }
 }
예제 #3
0
        public override void Initialize(IDictionary parameters)
        {
            base.Initialize(parameters);

            IoC.Instance.Register <IViewService, PackingViewService>();

            Assert.IsTrue(parameters.Contains(PackingPlaceParameterName));
            _packingPlace = (string)SerializationHelper.ConvertToTrueType(parameters[PackingPlaceParameterName], typeof(string));
            Assert.IsNotNull(_packingPlace);
            Assert.IsTrue(parameters.Contains(PackingTeParameterName));
            _packingTe = (string)SerializationHelper.ConvertToTrueType(parameters[PackingTeParameterName], typeof(string));
            Assert.IsTrue(parameters.Contains(PackingCountParameterName));
            _packingCount = (int)SerializationHelper.ConvertToTrueType(parameters[PackingCountParameterName], typeof(int));

            BPWorkflowManager.SetObjectCachable(PackWorkflowCodes.WfPack);

            _model = new PackingViewModel();

            // даем моделе время на инициализацию
            if (!new TaskFactory().StartNew(() =>
            {
                while (_model.AvailableTE == null || _model.PackingProducts == null)
                {
                    Thread.Sleep(1);
                }
            }).Wait(30000))
            {
                throw new TimeoutException("Истекло время создания модели");
            }

            if (!new TaskFactory().StartNew(() =>
            {
                _model.AvailableTE.Clear();
                _model.PackingProducts.Clear();
                _model.CurrentPlaceCode = null;
                _model.CurrentPlaceCode = _packingPlace;
                while (_model.AvailableTE.Count == 0 || _model.PackingProducts.Count == 0)
                {
                    Thread.Sleep(1);
                }
            }).Wait(30000))
            {
                throw new TimeoutException("Не удалось обновить данные");
            }

            _model.VisiblePackingProducts = _model.PackingProducts;

            var packTE = _model.AvailableTE.FirstOrDefault(i => i.GetKey <string>() == _packingTe);

            Assert.IsNotNull(packTE);

            _model.SelectedPack = packTE;
            _model.SetActivePackCommand.Execute(null);

            _model.SelectedPackingProducts.Clear();
            _model.SelectedPackingProducts.Add(_model.PackingProducts.First());

            var filters = FilterHelper.GetArrayFilterIn("barcodekey", _model.PackingProducts.Select(i => i.SKUID.ToString()).Distinct().Cast <object>(), " and barcode2entity = 'SKU'");

            using (var mgr = IoC.Instance.Resolve <IBaseManager <Barcode> >())
                _barcodes = mgr.GetFiltered(string.Join(";", filters), GetModeEnum.Partial).Select(j => j.BarcodeValue).ToArray();
        }