public EnterForm(EntranceContext context)
        {
            _context           = context ?? throw new ArgumentNullException(nameof(context));
            _entranceService   = _context.UnityContainer.Resolve <IEntranceService>();
            _formattingService = _context.UnityContainer.Resolve <IFormattingService>();

            if (ApplicationUtility.IsRunningOnMono)
            {
                Font = new Font("Arial", 8);
            }

            InitializeComponent();

            mTunableList.ServiceCommand += (sender, args) =>
            {
                switch (args.Command)
                {
                case "Remove":
                    removeButton_Click(this, null);
                    break;

                case "CellMouseDoubleClick":
                    enterButton_Click(this, null);
                    break;
                }
            };
        }
        public bool CheckCompatibility(EntranceContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException(nameof(context));
            }

            return(true);
        }
예제 #3
0
        public Form GetForm(EntranceContext context)
        {
            _context = context ?? throw new ArgumentNullException(nameof(context));

            var certificates = new KeySettingsService(context.UnityContainer).SelectCertificates();

            var step1IncomeValuesWrapper = new RegistrationFormValuesWrapper.Step1
            {
                Control5Certificate = certificates.Select(c => new ListItemContent(c)
                {
                    ImageKey = "Pfx"
                }).ToList()
            };

            _form =
                SubmitFormDisplayHelper.LoadSubmitFormByExtensionId(context.ExtensionManager, ExtensionCatalog.Registration,
                                                                    step1IncomeValuesWrapper.CollectIncomeValues());

            _form.ServiceCommand += (sender, args) =>
            {
                if (args.Command.Equals("BuildConnectionString", StringComparison.OrdinalIgnoreCase))
                {
                    BuildConnectionString((string)args.Argument);
                }
            };

            _form.WorkCallback = (step, list) =>
            {
                switch (step)
                {
                case 0:
                {
                    return(Step1(new RegistrationFormValuesWrapper.Step1(list)).CollectIncomeValues());
                }

                case 1:
                    Step2(new RegistrationFormValuesWrapper.Step2(list));
                    return(new Dictionary <string, object>());

                default:
                    throw new InvalidOperationException("step == " + step);
                }
            };

            return(_form);
        }
        public SessionContext GetIdentifierContext(EntranceContext context)
        {
            if (null == context)
            {
                throw new ArgumentNullException(nameof(context));
            }

            var form = new EnterForm(context);

            var template =
                TemplateLoader.LoadTemplate <TunableListTemplate>(context.ExtensionManager,
                                                                  ExtensionCatalog.Enter);

            form.ApplyTemplate(template);
            form.DisplayItems();

            if (DialogResult.OK != form.ShowDialog())
            {
                return(null);
            }

            return(new SessionContext(context, form.Session));
        }
예제 #5
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            LocalizationUtility.ApplyLanguage(LocalizationUtility.GetDefaultLanguage());

#if DEBUG
#else
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;
            Application.ThreadException += ApplicationOnThreadException;
#endif
            Application.ApplicationExit += ApplicationOnApplicationExit;

            // Первичная инициализация
            if (string.IsNullOrEmpty(Settings.Default.InstallationReference))
            {
                bool omitPrecompilation;

                if (ApplicationUtility.IsRunningOnMono)
                {
                    omitPrecompilation = true;
                }
                else
                {
                    var omitPrecompilationValue = ConfigurationManager.AppSettings["OmitPrecompilation"];

                    if (null != omitPrecompilationValue)
                    {
                        bool.TryParse(omitPrecompilationValue, out omitPrecompilation);
                    }
                    else
                    {
                        omitPrecompilation = false;
                    }
                }

                var initializationForm = new InitializationForm(omitPrecompilation);

                if (DialogResult.Cancel == initializationForm.ShowDialog())
                {
                    return;
                }
            }

            SplashScreenForm splashScreen = null;

            if (!ApplicationUtility.IsRunningOnMono)
            {
                var autoResetEvent = new AutoResetEvent(false);

                var thread = new Thread(() =>
                {
                    splashScreen = new SplashScreenForm();
                    autoResetEvent.Set();
                    Application.Run(splashScreen);
                })
                {
                    IsBackground = true
                };

                thread.Start();
                autoResetEvent.WaitOne();
            }

            try
            {
                _extensionManager = new ExtensionManager(Application.StartupPath);
            }
            catch (Exception exception)
            {
                // Закрываем SplashScreen
                splashScreen?.SafeClose();

                Logger.Fatal(exception.Message, exception);

                MessageBox.Show(Resources.Program_Main_An_error_occurred_while_trying_to_load_the_extension_manager_,
                                Resources.Program_Main_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // CustomAssemblyResolving
            _extensionManager.ApplyCustomAssemblyResolving();

            // WebMoney.Services configuration
            IConfigurationService configurationService;

            try
            {
                configurationService = _extensionManager.CreateExtension <IConfigurationService>();
            }
            catch (Exception)
            {
                // Закрываем SplashScreen
                splashScreen?.SafeClose();

                throw;
            }

            configurationService.InstallationReference = Settings.Default.InstallationReference;

            IUnityContainer unityContainer = new UnityContainer();
            configurationService.RegisterServices(unityContainer);

            // Set session
            var enterContext = new EntranceContext(_extensionManager, unityContainer);

            // Закрываем SplashScreen
            splashScreen?.SafeClose();

            var sessionContextProvider = _extensionManager.GetSessionContextProvider();

            SessionContext sessionContext;

            try
            {
                sessionContext = sessionContextProvider.GetIdentifierContext(enterContext);
            }
            catch (Exception exception)
            {
                Logger.Error(exception.Message, exception);

                MessageBox.Show(Resources.Program_Main_An_error_occurred_while_attempting_to_create_the_new_session_, Resources.Program_Main_Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (null == sessionContext)
            {
                return;
            }

            var session = sessionContext.Session;
            unityContainer.RegisterInstance(session);

            // Language
            var language = session.SettingsService.GetSettings().Language;
            LocalizationUtility.ApplyLanguage(language);

            var translator = new Translator();
            translator.Apply();

            // Run main form.
            var formProvider = _extensionManager.GetTopFormProvider(ExtensionCatalog.Main);
            var mainForm     = formProvider.GetForm(sessionContext);

            Application.Run(mainForm);
        }
예제 #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, EntranceContext entranceContext)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseJsonExceptionHandler(loggerFactory);
            }

            // entranceContext.EnsureSeedDataForContext();

            app.UseMiddleware <JwtInCookieMiddleware>();
            // app.UseMiddleware<JwtReissueMiddleware>();
            app.UseAuthentication();

            AutoMapper.Mapper.Initialize(config =>
            {
                config.CreateMap <LoginDto, Login>();
                config.CreateMap <Login, LoginCreateDto> ();
                config.CreateMap <User, LoginCreateDto> ();
                config.CreateMap <LoginCreateDto, Login>();
                config.CreateMap <LoginCreateDto, User>();
                config.CreateMap <Login, UserInfoDto> ();
                config.CreateMap <User, UserInfoDto> ();
                config.CreateMap <LoginCreateDto, UserInfoDto>();
                config.CreateMap <LoginModificationDto, Login>();
                config.CreateMap <UserModificationDto, User>();
            });

            app.UseCors("cors");

            app.UseMvc();

            #region Swagger
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "ApiHelp v1");
            });
            #endregion
        }