Example #1
0
        static void offp()
        {
            var pid            = 1;
            var rid            = 1;
            var sdate          = "2016/01/01";
            var edate          = "2016/08/08";
            var input          = "{\"principal\":" + pid + ",\"receiver\":" + rid + ",\"startdate\":\"" + sdate + "\",\"enddate\":\"" + edate + "\"}";
            var app            = new MFilesClientApplication();
            var vault          = app.BindToVault("8211", IntPtr.Zero, true, true);
            var FilterReceiver = vault.ExtensionMethodOperations.ExecuteVaultExtensionMethod("GetSecureNotice", input);

            Console.WriteLine(FilterReceiver);
            //  var filedata = eval('(' + FilterReceiver + ')');
            var filedata = JsonConvert.DeserializeObject <ReportPrintData>(FilterReceiver);
            // alert(filedata.objver.id);
            // var ObjID  = MFiles.CreateInstance("ObjID");
            //   ObjID.SetIDs (0,filedata);
            var objver = new ObjVer();

            objver.SetIDs(filedata.objtype, filedata.objid, filedata.objversion);
            var filever = new FileVer();

            filever.ID      = filedata.fileid;
            filever.Version = filedata.fileversion;
            vault.ObjectFileOperations.OpenFileInDefaultApplication(IntPtr.Zero, objver, filever,
                                                                    MFFileOpenMethod.MFFileOpenMethodOpen);
        }
        private void btn_Next_Click(object sender, EventArgs e)
        {
            if (lst_Vaults.SelectedIndex != -1)
            {
                //Bind to selected vault
                var lgnVault = clientApp.BindToVault(lst_Vaults.SelectedItem.ToString(), this.Handle, true, true);

                if (lgnVault != null)
                {
                    VaultOperations.LoggedInVault = lgnVault;
                    var clExamples = new ClientExamples();
                    clExamples.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Vault entry cancelled");
                }
            }
            else
            {
                MessageBox.Show("Please select a vault first");
            }
        }
Example #3
0
 private void Initialize()
 {
     _vault = App.BindToVault(Name, IntPtr.Zero, true, true);
     Guid   = _vault.GetGUID();
 }
        public void Launch(string applicationPath, dynamic dynVault, dynamic dynListItems)
        {
            if (!Debugger.IsAttached)
            {
                Debugger.Launch();
            }

            // TODO: heard this is bad, but don't have another way to do it currently
            // Need to set the app path because it is used later on to get the bin
            //AppDomain.CurrentDomain.SetData( "APPBASE", Path.Combine( applicationPath, "bin" ) );
            // Sets AppDomain.CurrentDomain.BaseDirectory
            AppDomain.CurrentDomain.SetData("APPBASE", applicationPath);

            AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;

            Console.WriteLine("Launching");

            this._console = new BufferedConsole();

            try
            {
                var config     = Config.Create(ScriptCsArgs.Parse(new string[] { }));
                var scriptArgs = new string[] { };
                config.Console = this._console;
                var scriptServicesBuilder = (ScriptServicesBuilder)ScriptServicesBuilderFactory.Create(config, scriptArgs);

                var clientApp       = new MFilesClientApplication();
                var clientVault     = clientApp.BindToVault((string)dynVault.Name, IntPtr.Zero, true, true);
                var props           = clientVault.PropertyDefOperations.GetPropertyDefs();
                var propsDictionary = new Dictionary <string, MFIdentifier>();
                foreach (PropertyDef propertyDef in props)
                {
                    // TODO: what if multiple have same name?
                    propsDictionary.Add(propertyDef.Name, new MFIdentifier(propertyDef.GUID));
                }
                var globs = new ScriptHostArguments
                {
                    Vault = clientVault,
                    // TODO: convert this list using clientVault to something useful
                    // TODO: move the script dashboard to non popup (that way we can pass the current listing)? what if there are multiple? (home page)
                    ListingItems = dynListItems,
                    Properties   = propsDictionary
                };
                var myFactory = new MFilesScriptHostFactory(globs, this._console);
                scriptServicesBuilder.SetOverride <IScriptHostFactory, MFilesScriptHostFactory>(myFactory);
                scriptServicesBuilder.SetOverride <IRepl, MFilesRepl>();
                var scriptServices = scriptServicesBuilder.Build();

                var runtimeServices = (RuntimeServices)scriptServicesBuilder.RuntimeServices;
                runtimeServices.Container.Resolve <Printers>().AddCustomPrinter <Vault>(vault => vault.Name);
                runtimeServices.Container.Resolve <Printers>().AddCustomPrinter <IVault>(vault => vault.Name);
                runtimeServices.Container.Resolve <Printers>().AddCustomPrinter <VaultClass>(vault => vault.Name);
                runtimeServices.Container.Resolve <Printers>().AddCustomPrinter <MFSearchBuilder>(search => $"Search for {search.Vault.Name} ({search.Conditions.Count})");

                this._command = new HtmlExecuteReplCommand(config.ScriptName, scriptArgs, scriptServices);
                this._command.Repl.Initialize();
                this._command.Execute();
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed to set up script services");
                Console.WriteLine(e);
            }
        }