예제 #1
0
        /// <summary>
        /// 此测试用例的目的在于测试消息头的发送是否成功
        /// </summary>
        static void Main()
        {
            //初始化容器
            InitContainer();

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //将登录信息存入约定位置
            AppDomain.CurrentDomain.SetData(SessionKey.CurrentUser, fakeLoginInfo);

            //实例化WCF客户端服务接口
            IClientContract clientContract = ResolveMediator.Resolve <IClientContract>();

            //调用服务获取消息头,
            string header = clientContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                Console.WriteLine("认证通过!");
            }

            ResolveMediator.Dispose();
            Console.ReadKey();
        }
        /// <summary>
        /// 重置密码
        /// </summary>
        public async void ResetPassword(Wrap <UserInfo> user)
        {
            ResetPasswordViewModel viewModel = ResolveMediator.Resolve <ResetPasswordViewModel>();

            viewModel.Load(user.Model.Number);
            await this._windowManager.ShowDialogAsync(viewModel);
        }
예제 #3
0
        public void Init()
        {
            //初始化配置文件
            Assembly      entryAssembly = Assembly.GetExecutingAssembly();
            Configuration configuration = ConfigurationExtension.GetConfigurationFromAssembly(entryAssembly);

            FrameworkSection.Initialize(configuration);
            DependencyInjectionSection.Initialize(configuration);
            RedisSection.Initialize(configuration);

            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            DbSession dbSession = new DbSession();

            dbSession.Database.EnsureCreated();

            this._unitOfWork = ResolveMediator.Resolve <IUnitOfWorkStub>();

            GlobalSetting.InitCurrentSessionId();
        }
예제 #4
0
        /// <summary>
        /// 此测试用例的目的在于测试消息头的发送是否成功
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            //初始化容器
            InitContainer();

            //伪造一个登录信息
            IAuthenticationContract authenticationContract = ResolveMediator.Resolve <IAuthenticationContract>();
            LoginInfo fakeLoginInfo = authenticationContract.Login(CommonConstants.AdminLoginId, CommonConstants.InitialPassword);

            //将登录信息存入约定位置
            base.Session.Add(SessionKey.CurrentUser, fakeLoginInfo);

            //实例化WCF服务端服务接口
            IServerContract serverContract = ResolveMediator.Resolve <IServerContract>();

            //调用服务获取消息头
            string header = serverContract.GetHeader();

            //如果消息头内容即是上述伪造的公钥,即说明整个认证过程没问题
            if (fakeLoginInfo.PublicKey.ToString() == header)
            {
                base.Response.Write("认证通过!");
            }

            ResolveMediator.Dispose();
        }
예제 #5
0
 /// <summary>
 /// 清空未处理的领域事件
 /// </summary>
 internal static void ClearUncompletedEvents()
 {
     using (IEventStore eventStorer = ResolveMediator.Resolve <IEventStore>())
     {
         eventStorer.ClearUncompletedEvents();
     }
 }
예제 #6
0
        /// <summary>
        /// 打开飞窗
        /// </summary>
        /// <typeparam name="T">飞窗类型</typeparam>
        /// <returns>飞窗</returns>
        public T OpenFlyout <T>() where T : FlyoutBase
        {
            this.Flyout = ResolveMediator.Resolve <T>();
            this.Flyout.Open();

            return((T)this.Flyout);
        }
예제 #7
0
        public void TestResolveGeneric()
        {
            IProductContract productContract1 = ResolveMediator.Resolve <IProductContract>();
            IProductContract productContract2 = ResolveMediator.Resolve <IProductContract>();

            Assert.IsNotNull(productContract1);
            Assert.IsNotNull(productContract2);
        }
        /// <summary>
        /// 创建信息系统
        /// </summary>
        public async void CreateInfoSystem()
        {
            AddViewModel viewModel = ResolveMediator.Resolve <AddViewModel>();
            bool?        result    = await this._windowManager.ShowDialogAsync(viewModel);

            if (result == true)
            {
                await this.ReloadInfoSystems();
            }
        }
예제 #9
0
 /// <summary>
 /// 处理未处理的领域事件(异步)
 /// </summary>
 internal static async Task HandleUncompletedEventsAsync()
 {
     await Task.Run(() =>
     {
         using (IEventStore eventStorer = ResolveMediator.Resolve <IEventStore>())
         {
             eventStorer.HandleUncompletedEvents();
         }
     });
 }
예제 #10
0
        /// <summary>
        /// 关联权限
        /// </summary>
        /// <param name="menu">菜单</param>
        public async void RelateAuthorities(Models.Menu menu)
        {
            this.Busy();

            RelateAuthorityViewModel viewModel = ResolveMediator.Resolve <RelateAuthorityViewModel>();
            await viewModel.Load(menu.Id);

            this.Idle();

            await this._windowManager.ShowDialogAsync(viewModel);
        }
        /// <summary>
        /// 分配角色
        /// </summary>
        public async void RelateRoles(Wrap <UserInfo> user)
        {
            this.Busy();

            RelateRoleViewModel viewModel = ResolveMediator.Resolve <RelateRoleViewModel>();
            await viewModel.Load(user.Model.Number);

            this.Idle();

            await this._windowManager.ShowDialogAsync(viewModel);
        }
예제 #12
0
 /// <summary>
 /// 挂起领域事件
 /// </summary>
 /// <typeparam name="T">领域事件源类型</typeparam>
 /// <param name="eventSource">领域事件源</param>
 public static void Suspend <T>(T eventSource) where T : class, IEvent
 {
     using (IEventStore eventStorer = ResolveMediator.Resolve <IEventStore>())
     {
         using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress, TransactionScopeAsyncFlowOption.Enabled))
         {
             eventStorer.Suspend(eventSource);
             scope.Complete();
         }
     }
 }
        /// <summary>
        /// 重置私钥
        /// </summary>
        public async void ResetPrivateKey(Wrap <UserInfo> user)
        {
            ResetPrivateKeyViewModel viewModel = ResolveMediator.Resolve <ResetPrivateKeyViewModel>();

            viewModel.Load(user.Model);
            bool?result = await this._windowManager.ShowDialogAsync(viewModel);

            if (result == true)
            {
                await this.ReloadUsers();
            }
        }
        /// <summary>
        /// 创建权限
        /// </summary>
        public async void CreateAuthority()
        {
            AddViewModel viewModel = ResolveMediator.Resolve <AddViewModel>();

            viewModel.Load(this.InfoSystems);
            bool?result = await this._windowManager.ShowDialogAsync(viewModel);

            if (result == true)
            {
                await this.ReloadAuthorities();
            }
        }
예제 #15
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //初始化依赖注入容器
            InitContainer();

            MainWindow mainWindow = ResolveMediator.Resolve <MainWindow>();

            Application.Run(mainWindow);
        }
예제 #16
0
        /// <summary>
        /// 修改菜单
        /// </summary>
        /// <param name="menu">菜单</param>
        public async void UpdateMenu(Models.Menu menu)
        {
            UpdateViewModel viewModel = ResolveMediator.Resolve <UpdateViewModel>();

            viewModel.Load(menu);
            bool?result = await this._windowManager.ShowDialogAsync(viewModel);

            if (result == true)
            {
                await this.ReloadMenus();
            }
        }
        /// <summary>
        /// 修改权限
        /// </summary>
        /// <param name="authority">权限</param>
        public async void UpdateAuthority(Wrap <AuthorityInfo> authority)
        {
            UpdateViewModel viewModel = ResolveMediator.Resolve <UpdateViewModel>();

            viewModel.Load(authority.Model);
            bool?result = await this._windowManager.ShowDialogAsync(viewModel);

            if (result == true)
            {
                await this.ReloadAuthorities();
            }
        }
        /// <summary>
        /// 初始化信息系统
        /// </summary>
        /// <param name="infoSystem">信息系统</param>
        public async void InitInfoSystem(Wrap <InfoSystemInfo> infoSystem)
        {
            InitViewModel viewModel = ResolveMediator.Resolve <InitViewModel>();

            viewModel.Load(infoSystem.Model);

            bool?result = await this._windowManager.ShowDialogAsync(viewModel);

            if (result == true)
            {
                await this.ReloadInfoSystems();
            }
        }
예제 #19
0
        /// <summary>
        /// 打开飞窗
        /// </summary>
        /// <param name="type">飞窗类型</param>
        /// <returns>飞窗</returns>
        public FlyoutBase OpenFlyout(Type type)
        {
            //验证
            if (!type.IsSubclassOf(typeof(FlyoutBase)))
            {
                throw new InvalidCastException("给定类型不是飞窗!");
            }

            this.Flyout = (FlyoutBase)ResolveMediator.Resolve(type);
            this.Flyout.Open();

            return(this.Flyout);
        }
예제 #20
0
        /// <summary>
        /// 打开文档
        /// </summary>
        /// <typeparam name="T">文档类型</typeparam>
        /// <returns>文档</returns>
        public T OpenDocument <T>() where T : DocumentBase
        {
            DocumentBase document = this.Documents.SingleOrDefault(x => x.GetType().FullName == typeof(T).FullName);

            if (document == null)
            {
                document = ResolveMediator.Resolve <T>();
                this.Documents.Add(document);
            }

            document.Open();

            return((T)document);
        }
예제 #21
0
        /// <summary>
        /// 命令执行者
        /// </summary>
        /// <param name="commandType">命令类型</param>
        /// <returns>命令执行者</returns>
        public static object GetCommandExecutorFor(Type commandType)
        {
            #region # 验证类型

            if (!typeof(ICommand).IsAssignableFrom(commandType))
            {
                throw new InvalidOperationException(string.Format("类型\"{0}\"不实现命令基接口!", commandType.FullName));
            }

            #endregion

            Type executorType = typeof(ICommandExecutor <>).MakeGenericType(commandType);

            return(ResolveMediator.Resolve(executorType));
        }
        public void Init()
        {
            //初始化依赖注入容器
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection serviceCollection = ResolveMediator.GetServiceCollection();
                serviceCollection.RegisterConfigs();
                ResolveMediator.Build();
            }

            DbSession dbSession = new DbSession(GlobalSetting.WriteConnectionString);

            dbSession.Database.CreateIfNotExists();

            this._unitOfWork = ResolveMediator.Resolve <IUnitOfWorkStub>();
        }
예제 #23
0
        /// <summary>
        /// 主活动创建事件
        /// </summary>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            Forms.Init(this, savedInstanceState);

            //初始化应用程序
            Startup startup = ResolveMediator.Resolve <Startup>();

            base.LoadApplication(startup);

            //注册未处理异常事件
            AndroidEnvironment.UnhandledExceptionRaiser += this.OnAndroidException;
            AppDomain.CurrentDomain.UnhandledException  += this.OnAppDomainException;
        }
예제 #24
0
        /// <summary>
        /// 重定向页面
        /// </summary>
        public static void Redirect <TViewModel>(this NavigateHelper <TViewModel> navigateHelper, bool animated = true)
        {
            //获取导航页
            NavigationPage navigationPage = ResolveMediator.Resolve <NavigationPage>();

            //获取导航前页面
            IList <Page> prevPages = new List <Page>(navigationPage.Navigation.NavigationStack);

            //导航至新页面
            navigateHelper.Navigate(animated);

            //移除导航前页面
            foreach (Page prevPage in prevPages)
            {
                navigationPage.Navigation.RemovePage(prevPage);
            }
        }
예제 #25
0
        //Actions

        #region 导航至菜单 —— async void Navigate(LoginMenuInfo menu)
        /// <summary>
        /// 导航至菜单
        /// </summary>
        /// <param name="menu">菜单</param>
        public async void Navigate(LoginMenuInfo menu)
        {
            if (!string.IsNullOrWhiteSpace(menu.Url))
            {
                this.Busy();

                Type    type     = Type.GetType(menu.Url);
                IScreen document = (IScreen)ResolveMediator.Resolve(type);
                document.DisplayName = menu.Name;

                await this.ActivateItem(document);

                this.ActiveDocument = document;

                this.Idle();
            }
        }
예제 #26
0
        /// <summary>
        /// 注销登录
        /// </summary>
        public async void Logout()
        {
            MessageBoxResult result = MessageBox.Show("确定要注销吗?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning);

            if (result == MessageBoxResult.Yes)
            {
                //清空Session
                MembershipMediator.SetLoginInfo(null);

                //跳转到登录窗体
                LoginViewModel loginViewModel = ResolveMediator.Resolve <LoginViewModel>();
                await this._windowManager.ShowWindowAsync(loginViewModel);

                //关闭当前窗口
                await base.TryCloseAsync();
            }
        }
예제 #27
0
        /// <summary>
        /// 重定向页面
        /// </summary>
        public static async Task RedirectToViewModelAsync <TViewModel>(this INavigationService navigationService, bool animated = true)
        {
            //获取导航页
            NavigationPage navigationPage = ResolveMediator.Resolve <NavigationPage>();

            //获取导航前页面
            IList <Page> prevPages = new List <Page>(navigationPage.Navigation.NavigationStack);

            //导航至新页面
            await navigationService.NavigateToViewModelAsync <TViewModel>(animated);

            //移除导航前页面
            foreach (Page prevPage in prevPages)
            {
                navigationPage.Navigation.RemovePage(prevPage);
            }
        }
예제 #28
0
        public void Init()
        {
            if (!ResolveMediator.ContainerBuilt)
            {
                IServiceCollection builder = ResolveMediator.GetServiceCollection();
                builder.RegisterConfigs();

                ResolveMediator.Build();
            }

            DbSession dbSession = new DbSession();

            dbSession.Database.CreateIfNotExists();

            this._unitOfWork = ResolveMediator.Resolve <IUnitOfWorkStub>();

            GlobalSetting.InitCurrentSessionId();
        }
예제 #29
0
        /// <summary>
        /// 打开文档
        /// </summary>
        /// <param name="type">文档类型</param>
        /// <returns>文档</returns>
        public DocumentBase OpenDocument(Type type)
        {
            //验证
            if (!type.IsSubclassOf(typeof(DocumentBase)))
            {
                throw new InvalidCastException("给定类型不是文档!");
            }

            DocumentBase document = this.Documents.SingleOrDefault(x => x.GetType().FullName == type.FullName);

            if (document == null)
            {
                document = (DocumentBase)ResolveMediator.Resolve(type);
                this.Documents.Add(document);
            }

            document.Open();

            return(document);
        }
예제 #30
0
        /// <summary>
        /// 展示对话框
        /// </summary>
        public static async Task <bool?> ShowDialogAsync(this INavigationService navigationService, Screen viewModel)
        {
            Element view   = ViewLocator.LocateForModelType(viewModel.GetType(), null, null);
            Dialog  dialog = view as Dialog;

            #region # 验证

            if (dialog == null)
            {
                throw new NotSupportedException($"\"{view.GetType()}\"未继承\"{typeof(Dialog)}\"!");
            }

            #endregion

            ViewModelBinder.Bind(viewModel, view, null);

            NavigationPage navigationPage = ResolveMediator.Resolve <NavigationPage>();
            bool?          result         = await navigationPage.Navigation.ShowPopupAsync(dialog);

            return(result);
        }