public DirectorySelectionForm(ConfigurationV1 configuration, string localPath, string appDataPath)
        {
            InitializeComponent();

            this._configuration = configuration;
            this._localPath     = localPath;
            this._appDataPath   = appDataPath;

            this._configuration.OptionsPath = null;

            // Ensure this is the only process checking these directories
            Mutex mutex = new Mutex(false, "VhaChat_DirectoryCheck");

            mutex.WaitOne();
            try
            {
                this._defaultDirectory.Enabled = this._testDirectory(localPath);
                this._appData.Enabled          = this._testDirectory(appDataPath);
            }
            finally
            {
                mutex.ReleaseMutex();
                mutex = null;
            }
        }
        public async Task Execute(IUserLoadTestHttpClient loadLoadTestHttpClient)
        {
            var test = new ConfigurationV1(loadLoadTestHttpClient, "CPQ_DEV", "Default", "Reservation")
                       .WithIntegrationParameter("ReservationJSON", "", "string")
                       .WithIntegrationParameter("ReferralSourceCode", "", "string")
                       .WithIntegrationParameter("CallingApp", "", "string")
                       .WithIntegrationParameter("Mode", "Reservation", "string")
                       .WithIntegrationParameter("CurrencyCode", "", "string")
                       .WithIntegrationParameter("ExchangeRate", "1", "number");

            try
            {
                await test.StartAsync();

                //await test.ConfigureAsync("ReservationLocation<font color=red>*</font>", "SJUT11ZE", "Location");
                await test.ConfigureAsync("ReservationLocation<font color=red>*</font>", "SJUT11ZE", "Location");

                await test.ConfigureWithRandomOptionAsync("VehicleClass<font color=red>*</font>", new [] { "ANCONL" }, "Vehicle");

                await test.Finalize();

                Console.WriteLine();
            }
            catch (System.Exception)
            {
                Console.WriteLine($"FAILED");
                await test.Cancel();

                //throw e;
            }
        }
Beispiel #3
0
 public Configuration(ConfigurationV1 config)
 {
     if (config.OptionsPath == null)
     {
         this._optionsPath = "";
         this._readOnly    = true;
     }
     else
     {
         this._optionsPath = config.OptionsPath;
         this._readOnly    = false;
     }
     this._optionsFile = config.OptionsFile;
     this._ignoresFile = config.IgnoresFile;
     this._outputMode  = config.OutputMode;
     this._dimensions  = config.Dimensions.ConvertAll <Dimension>(
         new Converter <ConfigurationV1Dimension, Dimension>(this._convertDimension))
                         .ToArray();
 }
Beispiel #4
0
        static void Main()
        {
            // Check security
            try
            {
                SecurityPermission permissions = new SecurityPermission(PermissionState.Unrestricted);
                permissions.Demand();
            }
            catch (SecurityException)
            {
                MessageBox.Show(
                    "Vha.Chat was unable to obtain the required execution permissions.\n" +
                    "This might be because you're attempting to run this application from a network drive or due to specific restrictions setup on your machine.\n\n" +
                    "This application will now close.",
                    "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Initialize Windows.Forms application
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);
#if !DEBUG
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(UnhandledException);
#endif

            // Fix working directory
            string path = Assembly.GetExecutingAssembly().Location;
            if (path.LastIndexOf(Path.DirectorySeparatorChar) > 0)
            {
                path = Path.GetDirectoryName(path);
                Environment.CurrentDirectory = path;
            }

            // Load initial configuration
            Data.Base data = Data.Base.Load("Configuration.xml");
            if (data == null)
            {
                data = new Data.ConfigurationV1();
            }
            while (data.CanUpgrade)
            {
                data = data.Upgrade();
            }
            if (data.Type != typeof(ConfigurationV1))
            {
                throw new ArgumentException("Unexpected data type in Configuration.xml: " + data.Type.ToString());
            }
            ConfigurationV1 configData = (ConfigurationV1)data;

            // Detect folders
            string defaultPath          = Path.GetFullPath(configData.OptionsPath);
            bool   defaultOptionsExists = File.Exists(defaultPath + Path.DirectorySeparatorChar + configData.OptionsFile);
            string appDataPath          = string.Format("{1}{0}{2}",
                                                        Path.DirectorySeparatorChar, Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Vha.Chat");
            bool appDataOptionsExists = File.Exists(appDataPath + Path.DirectorySeparatorChar + configData.OptionsFile);

            // Determine default folder
            if (defaultOptionsExists)
            {
                configData.OptionsPath = defaultPath;
            }
            else if (appDataOptionsExists)
            {
                configData.OptionsPath = appDataPath;
            }
            else
            {
                // Show directory selection form
                DirectorySelectionForm form = new DirectorySelectionForm(
                    configData, defaultPath, appDataPath);
                Application.Run(form);
                // Guess the user didn't like Vha.Chat :(
                if (form.DialogResult != DialogResult.OK)
                {
                    return;
                }
            }

            // Create context
            Configuration configuration = new Configuration(configData);
            Context       context       = new Context(configuration);
            context.Options.Save();
#if !DEBUG
            context.ExceptionEvent += new Handler <Exception>(UnhandledException);
#endif

            // Store config directory
            ApplicationConfigDirectory = configData.OptionsPath;

            // Start application
            ApplicationContext          = new ApplicationContext();
            ApplicationContext.MainForm = new AuthenticationForm(context);
            Application.Run(ApplicationContext);
        }