Exemple #1
0
 public GroupViewModel(IGroupRepository repository) : base(repository)
 {
     userRepository = NetCoreProvider.Get <IUserRepository>();
     AddUserCommand = new RelayCommand <UserDto>(arg =>
     {
         if (arg == null)
         {
             return;
         }
         var u = GroupDto.GroupUsers?.FirstOrDefault(t => t.Account == arg.Account);
         if (u == null)
         {
             GroupDto.GroupUsers?.Add(new GroupUserDto()
             {
                 Account = arg.Account
             });
         }
     });
     DelUserCommand = new RelayCommand <GroupUserDto>(arg =>
     {
         if (arg == null)
         {
             return;
         }
         var u = GroupDto.GroupUsers?.FirstOrDefault(t => t.Account == arg.Account);
         if (u != null)
         {
             GroupDto.GroupUsers?.Remove(u);
         }
     });
     groupRepository = repository;
 }
Exemple #2
0
 public GroupViewModel()
 {
     SelectPageTitle = "部门管理";
     NetCoreProvider.Get(out service);
     AddUserCommand = new RelayCommand <User>(arg =>
     {
         if (arg == null)
         {
             return;
         }
         var u = GroupHeader.GroupUsers?.FirstOrDefault(t => t.Account == arg.Account);
         if (u == null)
         {
             GroupHeader.GroupUsers?.Add(new GroupUser()
             {
                 Account = arg.Account
             });
         }
     });
     DelUserCommand = new RelayCommand <GroupUser>(arg =>
     {
         if (arg == null)
         {
             return;
         }
         var u = GroupHeader.GroupUsers?.FirstOrDefault(t => t.Account == arg.Account);
         if (u != null)
         {
             GroupHeader.GroupUsers?.Remove(u);
         }
     });
 }
Exemple #3
0
        protected override async void OnStartup(StartupEventArgs e)
        {
            Contract.serverUrl = ConfigurationManager.AppSettings["serverAddress"];
            var container = ConfigureServices();

            NetCoreProvider.RegisterServiceLocator(container);
            var login = NetCoreProvider.Get <IModuleDialog>("LoginCenter");
            await login.ShowDialog();

            #region 2020-10-10 未启用部分的待更新ASP.NETCore 依赖注入

            //var service = new ServiceCollection();
            ////注册日志服务
            //service.AddSingleton<ILog, ConsumptionNLog>();
            ////注册HTTP服务依赖关系
            //service.AddCustomRepository<UserService, IUserRepository>()
            //    .AddCustomRepository<GroupService, IGroupRepository>()
            //    .AddCustomRepository<MenuService, IMenuRepository>()
            //    .AddCustomRepository<BasicService, IBasicRepository>();
            ////注册ViewModel依赖关系
            //service.AddCustomViewModel<UserViewModel, IUserViewModel>()
            // .AddCustomViewModel<GroupViewModel, IGroupViewModel>()
            // .AddCustomViewModel<MenuViewModel, IMenuViewModel>()
            // .AddCustomViewModel<BasicViewModel, IBasicViewModel>();
            ////注册ViewCenter依赖关系
            //service.AddCustomViewCenter<LoginCenter>();
            //ServiceProvider = service.BuildServiceProvider();

            #endregion
        }
Exemple #4
0
        /// <summary>
        /// 打开页面
        /// </summary>
        /// <param name="pageName"></param>
        /// <returns></returns>
        public async virtual Task OpenPage(string pageName)
        {
            if (string.IsNullOrWhiteSpace(pageName))
            {
                return;
            }
            var pageModule = this.ModuleManager.Modules.FirstOrDefault(t => t.Name.Equals(pageName));

            if (pageModule == null)
            {
                return;
            }

            var module = this.ModuleList.FirstOrDefault(t => t.Name == pageModule.Name);

            if (module == null)
            {
                IBaseModule dialog = NetCoreProvider.Get <IBaseModule>(pageModule.TypeName);
                await dialog.BindDefaultModel(pageModule.Auth);

                this.ModuleList.Add(new ModuleUIComponent()
                {
                    Code     = pageModule.Code,
                    Auth     = pageModule.Auth,
                    Name     = pageModule.Name,
                    TypeName = pageModule.TypeName,
                    Body     = dialog.GetView()
                });
                this.CurrentModule = this.ModuleList.Last();
            }
            else
            {
                this.CurrentModule = module;
            }
        }
        /// <summary>
        /// 弹出窗口
        /// </summary>
        /// <param name="notify">类型</param>
        /// <param name="msg">文本信息</param>
        /// <returns></returns>
        private static async Task <bool> Show(Notify notify, string msg)
        {
            string Icon  = string.Empty;
            string Color = string.Empty;

            switch (notify)
            {
            case Notify.Error:
                Icon  = "CommentRemoveOutline";
                Color = "#FF4500";
                break;

            case Notify.Warning:
                Icon  = "CommentWarning";
                Color = "#FF8247";
                break;

            case Notify.Info:
                Icon  = "CommentProcessingOutline";
                Color = "#1C86EE";
                break;

            case Notify.Question:
                Icon  = "CommentQuestionOutline";
                Color = "#20B2AA";
                break;
            }
            var dialog = NetCoreProvider.Get <IMsg>("MsgCenter");

            return(await dialog.Show(new { Msg = msg, Color, Icon }));
        }
Exemple #6
0
 public override void SubscribeMessenger()
 {
     //执行菜单模块动画
     Messenger.Default.Register <string>(View, "WindowMinimized", arg =>
     {
         View.WindowState = System.Windows.WindowState.Minimized;
     });
     Messenger.Default.Register <string>(View, "ExpandMenu", arg =>
     {
         if (View.grdLeftMenu.Width < 200)
         {
             AnimationHelper
             .CreateWidthChangedAnimation(View.grdLeftMenu, 60, 200, new TimeSpan(0, 0, 0, 0, 250));
         }
         else
         {
             AnimationHelper
             .CreateWidthChangedAnimation(View.grdLeftMenu, 200, 60, new TimeSpan(0, 0, 0, 0, 250));
         }
     });
     //执行返回首页
     Messenger.Default.Register <string>(View, "GoHomePage", arg =>
     {
         GoHomeView();
     });
     Messenger.Default.Register <Module>(View, "NavigationNewPage", async m =>
     {
         try
         {
             if (m.TypeName == View.page.Tag?.ToString())
             {
                 return;
             }
             _ = DialogHost.Show(new SplashScreenView()
             {
                 DataContext = new { Msg = "正在打开页面..." }
             }, "Root");
             ViewModel.DialogIsOpen = true;
             await Task.Delay(100);
             //将数据库中获取的菜单Namespace在容器当中查找依赖关系的实例
             var dialog = NetCoreProvider.Get <IModule>(m.TypeName);
             await dialog.BindDefaultModel(m.Auth);
             View.page.Tag     = m.TypeName;
             View.page.Content = dialog.GetView();
         }
         catch (Exception ex)
         {
             Log.Error(ex.Message);
         }
         finally
         {
             ViewModel.DialogIsOpen = false; //关闭等待窗口
             GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
             GC.Collect();
         }
     });
 }
        protected override async void OnStartup(StartupEventArgs e)
        {
            Contract.serverUrl = ConfigurationManager.AppSettings["serverAddress"];
            var container = ConfigureServices();

            NetCoreProvider.RegisterServiceLocator(container);
            var login = NetCoreProvider.Get <IModuleDialog>("LoginCenter");
            await login.ShowDialog();
        }
Exemple #8
0
        /// <summary>
        /// 临时固定,后期修改动态绑定 2020-07-19
        /// </summary>
        void InitHomeView()
        {
            NetCoreProvider.Get("HomeCenter", out IModule dialog);
            dialog.BindDefaultModel();
            ModuleUIComponent component = new ModuleUIComponent();

            component.Name = "首页";
            component.Body = dialog.GetView();
            ViewModel.ModuleList.Add(component);
            ViewModel.ModuleManager.Modules.Add(component);
            ViewModel.CurrentModule = ViewModel.ModuleList[ViewModel.ModuleList.Count - 1];
        }
        public async virtual void OpenPage(string pageName)
        {
            if (string.IsNullOrWhiteSpace(pageName))
            {
                return;
            }
            var m = ModuleManager.Modules.FirstOrDefault(t => t.Name.Equals(pageName));

            if (m == null)
            {
                return;
            }
            var module = ModuleList.FirstOrDefault(t => t.Name == m.Name);

            if (module == null)
            {
                var dialog = NetCoreProvider.Get <IBusinessModule>(m.TypeName);
                if (dialog != null)
                {
                    await dialog.BindDefaultModel(m.Auth);

                    ModuleList.Add(new ModuleUIComponent()
                    {
                        Code     = m.Code,
                        Auth     = m.Auth,
                        Name     = m.Name,
                        TypeName = m.TypeName,
                        Body     = dialog.GetView()
                    });
                }
                else
                {
                    var dialogbase = NetCoreProvider.Get <IBaseModule>(m.TypeName);
                    dialogbase.BindDefaultModel();
                    ModuleList.Add(new ModuleUIComponent()
                    {
                        Code     = m.Code,
                        Name     = m.Name,
                        TypeName = m.TypeName,
                        Body     = dialogbase.GetView()
                    });
                }
                //将数据库中获取的菜单Namespace在容器当中查找依赖关系的实例
                CurrentModule = ModuleList[ModuleList.Count - 1];
                GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                GC.Collect();
            }
            else
            {
                CurrentModule = module;
            }
        }
        /// <summary>
        /// 初始化首页
        /// </summary>
        void InitHomeView()
        {
            var dialog = NetCoreProvider.Get <IBaseModule>("HomeCenter");

            dialog.BindDefaultModel();
            ModuleUIComponent component = new ModuleUIComponent();

            component.Name = "首页";
            component.Body = dialog.GetView();
            ModuleList.Add(component);
            ModuleManager.Modules.Add(component);
            CurrentModule = ModuleList[ModuleList.Count - 1];
        }
Exemple #11
0
 public override void SubscribeMessenger()
 {
     Messenger.Default.Register <string>(view, "Snackbar", arg =>
     {
         var messageQueue = view.SnackbarThree.MessageQueue;
         messageQueue.Enqueue(arg);
     });
     Messenger.Default.Register <bool>(view, "NavigationPage", async arg =>
     {
         var dialog = NetCoreProvider.Get <IModuleDialog>("MainCenter");
         view.Close();
         this.UnsubscribeMessenger();
         await dialog.ShowDialog();
     });
     base.SubscribeMessenger();
 }
Exemple #12
0
 public override void SubscribeMessenger()
 {
     WeakReferenceMessenger.Default.Register <string, string>(view, "Snackbar", (sender, arg) =>
     {
         App.Current.Dispatcher.BeginInvoke(new Action(() =>
         {
             var messageQueue = view.SnackbarThree.MessageQueue;
             messageQueue.Enqueue(arg);
         }));
     });
     WeakReferenceMessenger.Default.Register <string, string>(view, "NavigationPage", async(sender, arg) =>
     {
         var dialog = NetCoreProvider.Get <IModuleDialog>("MainCenter");
         this.UnsubscribeMessenger();
         view.Close();
         await dialog.ShowDialog();
     });
     base.SubscribeMessenger();
 }
Exemple #13
0
        public async virtual void OpenPage(string pageName)
        {
            if (string.IsNullOrWhiteSpace(pageName))
            {
                return;
            }
            var pageModule = viewModel.ModuleManager.Modules.FirstOrDefault(t => t.Name.Equals(pageName));

            if (pageModule == null)
            {
                return;
            }

            var module = viewModel.ModuleList.FirstOrDefault(t => t.Name == pageModule.Name);

            if (module == null)
            {
                IBaseModule dialog = NetCoreProvider.Get <IBaseModule>(pageModule.TypeName);
                await dialog.BindDefaultModel(pageModule.Auth);

                viewModel.ModuleList.Add(new ModuleUIComponent()
                {
                    Code     = pageModule.Code,
                    Auth     = pageModule.Auth,
                    Name     = pageModule.Name,
                    TypeName = pageModule.TypeName,
                    Body     = dialog.GetView()
                });
                viewModel.CurrentModule = viewModel.ModuleList.Last();
                GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                GC.Collect();
            }
            else
            {
                viewModel.CurrentModule = module;
            }
        }
Exemple #14
0
 public MenuCenter() : base(NetCoreProvider.Get <IMenuViewModel>())
 {
 }
Exemple #15
0
 public BasicCenter() : base(NetCoreProvider.Get <IBasicViewModel>())
 {
 }
 public MenuViewModel()
 {
     SelectPageTitle = "菜单管理";
     NetCoreProvider.Get(out service);
 }
Exemple #17
0
        public override void SubscribeMessenger()
        {
            //非阻塞式窗口提示消息
            Messenger.Default.Register <string>(View, "Snackbar", arg =>
            {
                var messageQueue = View.SnackbarThree.MessageQueue;
                messageQueue.Enqueue(arg);
            });
            //阻塞式窗口提示消息
            Messenger.Default.Register <MsgInfo>(View, "UpdateDialog", m =>
            {
                if (m.IsOpen)
                {
                    _ = DialogHost.Show(new SplashScreenView()
                    {
                        DataContext = new { Msg = m.Msg }
                    }, "Root");
                }
                else
                {
                    ViewModel.DialogIsOpen = false;
                }
            });
            //执行菜单模块动画
            Messenger.Default.Register <string>(View, "WindowMinimize", arg =>
            {
                View.WindowState = System.Windows.WindowState.Minimized;
            });
            Messenger.Default.Register <string>(View, "WindowMaximize", arg =>
            {
                if (View.WindowState == System.Windows.WindowState.Maximized)
                {
                    View.WindowState = System.Windows.WindowState.Normal;
                }
                else
                {
                    View.WindowState = System.Windows.WindowState.Maximized;
                }
            });
            //菜单执行相关动画及模板切换
            Messenger.Default.Register <string>(View, "ExpandMenu", arg =>
            {
                if (View.MENU.Width < 200)
                {
                    AnimationHelper.CreateWidthChangedAnimation(View.MENU, 60, 200, new TimeSpan(0, 0, 0, 0, 300));
                }
                else
                {
                    AnimationHelper.CreateWidthChangedAnimation(View.MENU, 200, 60, new TimeSpan(0, 0, 0, 0, 300));
                }
                for (int i = 0; i < ViewModel.ModuleManager.ModuleGroups.Count; i++)
                {
                    ViewModel.ModuleManager.ModuleGroups[i].ContractionTemplate = View.MENU.Width < 200 ? false : true;
                }

                //由于...
                var template = View.IC.ItemTemplateSelector;
                View.IC.ItemTemplateSelector = null;
                View.IC.ItemTemplateSelector = template;
            });
            //执行返回首页
            Messenger.Default.Register <string>(View, "GoHomePage", arg =>
            {
                InitHomeView();
            });
            //打开页面
            Messenger.Default.Register <string>(View, "OpenPage", async name =>
            {
                try
                {
                    if (string.IsNullOrWhiteSpace(name))
                    {
                        return;
                    }
                    var m = ViewModel.ModuleManager.Modules.FirstOrDefault(t => t.Name.Equals(name));
                    if (m == null)
                    {
                        return;
                    }
                    var module = ViewModel.ModuleList.FirstOrDefault(t => t.Name == m.Name);
                    if (module == null)
                    {
                        NetCoreProvider.Get <IModule>(m.TypeName, out IModule dialog);
                        if (dialog == null)
                        {
                            //404
                            return;
                        }
                        _ = DialogHost.Show(new SplashScreenView()
                        {
                            DataContext = new { Msg = "正在打开页面..." }
                        }, "Root");
                        ViewModel.DialogIsOpen = true;
                        await Task.Delay(100);
                        //将数据库中获取的菜单Namespace在容器当中查找依赖关系的实例
                        await dialog.BindDefaultModel(m.Auth);
                        ViewModel.ModuleList.Add(new ModuleUIComponent()
                        {
                            Code     = m.Code,
                            Auth     = m.Auth,
                            Name     = m.Name,
                            TypeName = m.TypeName,
                            Body     = dialog.GetView()
                        });
                        ViewModel.CurrentModule = ViewModel.ModuleList[ViewModel.ModuleList.Count - 1];
                    }
                    else
                    {
                        ViewModel.CurrentModule = module;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                }
                finally
                {
                    ViewModel.DialogIsOpen = false; //关闭等待窗口
                    GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                    GC.Collect();
                }
            });
            //关闭页面
            Messenger.Default.Register <string>(View, "ClosePage", m =>
            {
                try
                {
                    var module = ViewModel.ModuleList.FirstOrDefault(t => t.Name.Equals(m));
                    if (module != null)
                    {
                        ViewModel.ModuleList.Remove(module);
                        if (ViewModel.ModuleList.Count > 0)
                        {
                            ViewModel.CurrentModule = ViewModel
                                                      .ModuleList[ViewModel.ModuleList.Count - 1];
                        }
                        else
                        {
                            ViewModel.CurrentModule = null;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex.Message);
                }
                finally
                {
                    GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
                    GC.Collect();
                }
            });
            base.SubscribeMessenger();
        }
Exemple #18
0
 public LoginViewModel()
 {
     service      = NetCoreProvider.Get <IConsumptionService>();
     LoginCommand = new RelayCommand(Login);
 }
Exemple #19
0
 public UserCenter() : base(NetCoreProvider.Get <IUserViewModel>())
 {
 }
 public BasicViewModel()
 {
     service = NetCoreProvider.Get <IConsumptionService>();
 }
Exemple #21
0
 public GlobalLoger()
 {
     this.log = NetCoreProvider.Get <ILog>();
 }
Exemple #22
0
 public MenuViewModel()
 {
     menuService = NetCoreProvider.Get <IConsumptionService>();
 }
Exemple #23
0
 public GroupCenter() : base(NetCoreProvider.Get <IGroupViewModel>())
 {
 }
 public UserViewModel()
 {
     userService = NetCoreProvider.Get <IConsumptionService>();
 }
Exemple #25
0
 public UserViewModel()
 {
     NetCoreProvider.Get(out service);
 }
        public MenuViewModel() : base(NetCoreProvider.Get<IMenuRepository>())
        {

        }
 public LoginViewModel()
 {
     this.repository = NetCoreProvider.Get <IUserRepository>();
     LoginCommand    = new RelayCommand(Login);
 }
Exemple #28
0
 private void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     MessageBox.Show(e.Exception.Message);
     NetCoreProvider.Get <ILog>()?.Warn(e.Exception, e.Exception.Message);
     e.Handled = true;
 }
 public UserViewModel() : base(NetCoreProvider.Get <IUserRepository>())
 {
 }
 public BasicViewModel()
 {
     NetCoreProvider.Get(out service);
 }