Exemplo n.º 1
0
        public void AssertThat_ChildValidationFindings_AreAvailable()
        {
            int expected = 10;


            var conf = new Configuration()
            {
                Name        = "",
                ID          = 1234,
                ChildConfig = new Child_Configuration
                {
                    Name             = "",
                    GrandChildConfig = new GrandChild_Configuration
                    {
                        Name = ""
                    }
                }
            };
            var vault = new MFilesAPI.Vault();
            var va    = Helpers.InitializeTestVA(conf);
            var env   = va.CreateEventHandlerEnvironment(MFilesAPI.MFEventHandlerType.MFEventHandlerAfterCancelCheckout);

            va.ValidatorDispatcher.Dispatch(new ValidationCommand(vault));

            var command = new TestEnvironmentCommand(env)
            {
                TestedEnvironmentProperties = 0
            };

            Dispatcher dispatcher = va.EventDispatcher;

            dispatcher.Dispatch(command);

            Assert.AreEqual(expected, command.TestedEnvironmentProperties);
        }
Exemplo n.º 2
0
 public SignEditor(MFilesAPI.Vault vault, MailConfig config)
 {
     InitializeComponent();
     _vault  = vault;
     _config = config;
     Load   += OnLoad;
 }
Exemplo n.º 3
0
        private async void MainFrm_Load(object sender, EventArgs e)
        {
            this.lblStatus.Text = "正在读取邮箱配置...";
            await Task.Run(() =>
            {
                _vault  = MailCore.MF.MFilesUtil.GetVaultByName();
                _config = MailCore.MF.MfMailConfig.GetMailConfig(_vault);
            });

            if (String.IsNullOrEmpty(_config.Email))
            {
                MessageBox.Show("邮件地址为空,请先点击“设置”配置邮箱信息!",
                                "收信",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1);
                this.Close();
            }

            if (String.IsNullOrEmpty(_config.RecvAddr))
            {
                MessageBox.Show("POP服务器地址为空,请先点击“设置”配置邮箱信息!",
                                "收信",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Information,
                                MessageBoxDefaultButton.Button1);
                this.Close();
            }

            _bkWorker.DoWork             += BkWorkerOnDoWork;
            _bkWorker.ProgressChanged    += BkWorkerOnProgressChanged;
            _bkWorker.RunWorkerCompleted += BkWorkerOnRunWorkerCompleted;
            _bkWorker.RunWorkerAsync();
        }
Exemplo n.º 4
0
        public void AssertThat_EnvironmentVariablesAreAvailable()
        {
            int expected = 111;

            var conf = new Configuration()
            {
                Name = "", ID = 1234
            };
            var vault = new MFilesAPI.Vault();
            var va    = Helpers.InitializeTestVA(conf);
            var env   = va.CreateEventHandlerEnvironment(MFilesAPI.MFEventHandlerType.MFEventHandlerAfterBringOnline);

            va.ValidatorDispatcher.Dispatch(new ValidationCommand(vault));

            var command = new TestEnvironmentCommand(env)
            {
                TestedEnvironmentProperties = 0
            };

            Dispatcher dispatcher = va.EventDispatcher;

            dispatcher.Dispatch(command);

            Assert.AreEqual(expected, command.TestedEnvironmentProperties);
        }
Exemplo n.º 5
0
        public static LicensedVaultApplication <TConfig> InitializeLicensedTestVA <TConfig>(TConfig configuration, LicenseContentBase licenseContent = null)
            where TConfig : class, new()
        {
            var vaultApplication = new LicensedVaultApplication <TConfig>();
            var vault            = new MFilesAPI.Vault();

            vaultApplication.SetConfig(configuration);
            vaultApplication.licenseContent = licenseContent;
            vaultApplication.StartOperations(vault);
            vaultApplication.SetPermanentVault(vault);

            return(vaultApplication);
        }
Exemplo n.º 6
0
        private async void OnLoad(object sender, EventArgs eventArgs)
        {
            Text    = "邮箱设置 - 正在加载配置,请耐心等待...";
            Enabled = false;

            await Task.Run(() =>
            {
                _vault      = MFilesUtil.GetVaultByName();
                _initConfig = MfMailConfig.GetMailConfig(_vault);
            });

            Text    = "邮箱设置";
            Enabled = true;

            //获取用户名和邮箱
            if (String.IsNullOrEmpty(_initConfig.UserName) ||
                String.IsNullOrEmpty(_initConfig.Email))
            {
                var name  = String.Empty;
                var email = String.Empty;
                MfMailConfig.GetNameAndEmailFromVault(
                    _vault,
                    ref name,
                    ref email);
                _initConfig.UserName = name;
                _initConfig.Email    = email;
            }

            if (String.IsNullOrEmpty(_initConfig.RecvAddr))
            {
                _initConfig.RecvAddr = "pop3.dbworld.com";
            }

            if (String.IsNullOrEmpty(_initConfig.SendAddr))
            {
                _initConfig.SendAddr = "smtp.dbworld.com";
            }

            //初始化UI
            txtBoxUserName.Text           = _initConfig.UserName;
            txtBoxEmail.Text              = _initConfig.Email;
            txtBoxPwd.Text                = _initConfig.PassWord;
            txtBoxPopAddr.Text            = _initConfig.RecvAddr;
            txtBoxSmtpAddr.Text           = _initConfig.SendAddr;
            chkBoxPopSSL.Checked          = _initConfig.RecvSSL;
            chkBoxSmtpSSL.Checked         = _initConfig.SendSSL;
            txtBoxPopPort.Text            = _initConfig.RecvPort.ToString();
            txtBoxSmtpPort.Text           = _initConfig.SendPort.ToString();
            txtBoxMarkup.Text             = _initConfig.MarkUp;
            txtBoxUserName.SelectionStart = txtBoxUserName.Text.Length;
        }
Exemplo n.º 7
0
        public void Assert_BaseCase()
        {
            var expected = 1;

            var vault  = new MFilesAPI.Vault();
            var config = new Configuration {
                Name = "", ID = 42
            };

            var va = Helpers.InitializeTestVA(config);

            Dispatcher <IEnumerable <ValidationFinding> > dispatcher = va.ValidatorDispatcher;

            var command = new ValidationCommand(vault);

            var results = dispatcher.Dispatch(command);

            Assert.AreEqual(expected, results.Count());
        }
Exemplo n.º 8
0
        public void SpeedTest_100000Calls()
        {
            var vault  = new MFilesAPI.Vault();
            var config = new Configuration {
                Name = "", ID = 42
            };

            var va = Helpers.InitializeTestVA(config);

            Dispatcher <IEnumerable <ValidationFinding> > dispatcher = va.ValidatorDispatcher;

            dispatcher.IncludeAssemblies(typeof(Configuration));

            var command = new ValidationCommand(vault);

            for (int i = 0; i < 100000; i++)
            {
                var results = dispatcher.Dispatch(command);
            }

            Assert.IsTrue(true);
        }
        /// <summary>
        /// Deploys the M-Files Application to a client and launches it.
        /// </summary>
        /// <param name="grfLaunch">Launch flags</param>
        /// <returns>Success code</returns>
        public override int DebugLaunch(uint grfLaunch)
        {
            // TODO: For debugging, check the grfLaunch flags.
            // The flags differ for "Launch" and "Launch with debugging".
            CCITracing.TraceCall();

            // Resolve the test vault.
            var clientApp = new MFilesAPI.MFilesClientApplication();
            var vaultName = GetConfigurationProperty("TestVault", true);

            MFilesAPI.VaultConnection vaultConnection;

            try
            {
                // Try to get the connection.
                vaultConnection = clientApp.GetVaultConnection(vaultName);
            }
            catch
            {
                // Vault wasn't found, ask the user for a new one.
                var selectVaultDialog = new SelectVaultDialog();
                selectVaultDialog.ShowDialog();
                if (selectVaultDialog.Result == System.Windows.Forms.DialogResult.Cancel)
                {
                    return(VSConstants.S_FALSE);
                }

                // Get the user answer.
                vaultName       = selectVaultDialog.VaultName;
                vaultConnection = clientApp.GetVaultConnection(selectVaultDialog.VaultName);

                // If the user defined this as the default vault, save it in the project file.
                if (selectVaultDialog.SetDefault)
                {
                    this.SetConfigurationProperty("TestVault", selectVaultDialog.VaultName);
                }
            }

            // Get the M-Files install directory from the registry.
            var apiVersion = clientApp.GetAPIVersion().Display;
            var hklm64     = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
            var mfKey      = hklm64.OpenSubKey(@"Software\Motive\M-Files\" + apiVersion);
            var installDir = (string)mfKey.GetValue("InstallDir");

            mfKey.Close();
            hklm64.Close();

            // Log out to free the current application.
            MFilesAPI.Vault vault = null;
            try
            {
                vault = clientApp.BindToVault(vaultName, IntPtr.Zero, false, true);
                if (vault != null)
                {
                    vault.LogOutWithDialogs(IntPtr.Zero);
                }
            }
            catch
            {
                // We most likely weren't logged in so everything is okay.
            }

            // Deploy the application.
            string vaultGuid    = vaultConnection.GetGUID();
            var    relativePath = string.Format(@"Client\Apps\{0}\sysapps\{1}",
                                                vaultGuid, this.project.GetProjectProperty("Name") ?? "unnamed");
            var targetDir = Path.Combine(installDir, relativePath);

            // If the directory exists, remove it so there's no residue files left.
            if (Directory.Exists(targetDir))
            {
                Directory.Delete(targetDir, true);
            }
            Directory.CreateDirectory(targetDir);

            // Extract the Zip contents to the target directory.
            DeployPackage(targetDir);

            // Log back into the application.
            vault = clientApp.BindToVault(vaultName, IntPtr.Zero, true, true);

            // If vault is null, the user cancelled the login -> Exit
            if (vault == null)
            {
                return(VSConstants.S_FALSE);
            }

            // Figure out the launch mode.
            var launchMode = (GetConfigurationProperty("LaunchMode", false) ?? "").ToLowerInvariant();

            if (launchMode == "powershell")
            {
                // Create a powershell window to launch the application.

                // Create the initial state with the app and vault references.
                var builtInState = InitialSessionState.CreateDefault();
                builtInState.Variables.Add(new SessionStateVariableEntry(
                                               "app", clientApp, "M-Files Application"));
                builtInState.Variables.Add(new SessionStateVariableEntry(
                                               "vault", vault, "M-Files Vault"));
                Runspace runspace = RunspaceFactory.CreateRunspace(builtInState);

                // Run the script.
                runspace.Open();
                Pipeline pipeline = runspace.CreatePipeline();
                pipeline.Commands.AddScript(GetConfigurationProperty("LaunchPSScript", false) ?? "");
                pipeline.Invoke();
                runspace.Close();
            }
            else
            {
                // Launch the application by navigating to a path in the vault.
                var mfilesPath =
                    clientApp.GetDriveLetter() + ":\\" +
                    vaultName + "\\" +
                    GetConfigurationProperty("LaunchMFilesPath", false);

                Process.Start("explorer.exe", string.Format("\"{0}\"", mfilesPath));
            }

            return(VSConstants.S_OK);
        }