Ejemplo n.º 1
0
        /// <summary>
        /// Обновление модулей.
        /// </summary>
        public static void UpdateModules()
        {
            ClientDevelopmentUpdater.Instance.RefreshDevelopment();
            MetadataService.ConfigurationSettingsPaths = new Sungero.Domain.ClientConfigurationSettingsPaths(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            ClientLazyAssembliesResolver.Instance.LinkToAssembliesFolder(ClientDevelopmentUpdater.Instance.CacheFolder);

            var baseDirectory        = AppDomain.CurrentDomain.BaseDirectory;
            var developmentDirectory = ClientDevelopmentUpdater.Instance.CacheFolder;

            Dependency.RegisterType <IClientLinqExtensions, ClientLinqExtensionsService>();
            Dependency.RegisterType <IHyperlinkDisplayTextCache, HyperlinkDisplayTextCacheImplementer>();
            Dependency.RegisterType <IHyperlinkEntityCache, HyperlinkEntityCacheImplementer>();

            LoadModules(baseDirectory, "*Client.dll");
            LoadModules(baseDirectory, "*Shared.dll");
            LoadModules(baseDirectory, "*Base.dll");
            LoadModules(developmentDirectory, null);

            EntityFactory.ConfigureUnityContainer();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Зарегистрировать клиент.
        /// </summary>
        public static void Initialize()
        {
            DrxTransfer.Log.Console.Info("Регистрация клиента");
            LocalizationManager.Instance.AssignCurrentCulture();

            // Управление кэшами.
            var cacheConfigProvider = new CacheConfigProvider(null, false);

            Dependency.RegisterInstance <ICacheManager>(new CacheManagerImplementation(cacheConfigProvider));

            // Плагины.
            Dependency.RegisterInstance <Sungero.Plugins.IPluginManager>(new Sungero.Plugins.PluginManager(new Sungero.Domain.Client.ClientPluginDiscoverer(), new Sungero.Plugins.PluginSettingsLoader()));

            ServiceContext.Instance.ApplicationExit += (s, a) => { throw a.Exception; };
            if (UserCredentialsManager.IsRegistered)
            {
                return;
            }

            // Перенаправление вывода, чтобы не писать лишнюю информацию на экран.
            var consoleOut = Console.Out;

            try
            {
                Console.SetOut(System.IO.TextWriter.Null);
                Sungero.Domain.Client.SystemInfo.Tenant = CommandLine.options.Tenant;
                AuthenticationHelper.Register(CommandLine.options, false);
                Console.SetOut(consoleOut);
            }
            catch (InvalidSecurityException ex)
            {
                Console.SetOut(consoleOut);
                throw new InvalidSecurityException(ex.IsInternal, new LocalizedString("No access rights to the system - invalid username or password."), ex);
            }
            catch (Exception)
            {
                Console.SetOut(consoleOut);
                throw;
            }

            #region Загрузка модулей.
            Log.Info("Загрузка модулей.");
            DrxTransfer.Log.Console.Info("Загрузка модулей");
            ClientDevelopmentUpdater.Instance.RefreshDevelopment();
            MetadataService.ConfigurationSettingsPaths = new Sungero.Domain.ClientConfigurationSettingsPaths();
            AssemblyResolver.Instance.AddStore <ClientLazyAssembliesStore>(ClientDevelopmentUpdater.Instance.CacheFolder);

            var baseDirectory        = AppDomain.CurrentDomain.BaseDirectory;
            var developmentDirectory = ClientDevelopmentUpdater.Instance.CacheFolder;

            Dependency.RegisterType <IClientLinqExtensions, ClientLinqExtensionsService>();
            Dependency.RegisterType <IHyperlinkEntityCache, HyperlinkEntityCacheImplementer>();
            Dependency.RegisterType <IHyperlinkDisplayTextCache, HyperlinkDisplayTextCacheImplementer>();

            LoadModules(baseDirectory, "*Client.dll");
            LoadModules(developmentDirectory, null);

            EntityFactory.ConfigureUnityContainer();

            #endregion

            var tenantCulture = TenantInfo.Culture;
            if (!LocalizationManager.Instance.ClientUICulture.Equals(tenantCulture))
            {
                Log.Warn(string.Format("Client culture changed to {0}", tenantCulture));
                LocalizationManager.Instance.SetSystemLanguage(tenantCulture.Name);
                LocalizationManager.Instance.AssignCurrentCulture();
                Cleanup();
                AuthenticationHelper.Register(CommandLine.options, false);
            }
        }