示例#1
0
        /// <summary>
        /// Downloads the configuration of the specified application.
        /// </summary>
        private void DownloadAppConfig(ProjectApp app)
        {
            transferControl.ThrowIfCancellationRequested();
            transferControl.WriteLine();
            transferControl.WriteMessage(string.Format(AdminPhrases.DownloadAppConfig, app.AppName));

            string sql = $"SELECT path, contents FROM {Schema}.app_config WHERE app_id = @appID" +
                         (downloadOptions.IgnoreRegKeys ? $" AND path NOT LIKE '%{ScadaUtils.RegFileSuffix}'" : "");
            NpgsqlCommand cmd = new(sql, conn);

            cmd.Parameters.AddWithValue("appID", (int)app.ServiceApp);
            int fileCount = 0;

            using NpgsqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read() && !reader.IsDBNull(1))
            {
                transferControl.ThrowIfCancellationRequested();
                string path = reader.GetString(0);
                transferControl.WriteMessage(string.Format(ExtensionPhrases.DownloadConfigFile, path));

                string absolutePath = Path.Combine(app.ConfigDir, path);
                Directory.CreateDirectory(Path.GetDirectoryName(absolutePath));
                File.WriteAllText(absolutePath, reader.GetString(1), Encoding.UTF8);
                fileCount++;
            }

            transferControl.WriteMessage(string.Format(AdminPhrases.FileCount, fileCount));
            progressTracker.TaskIndex++;
        }
示例#2
0
 /// <summary>
 /// Determines whether the application is enabled or not.
 /// </summary>
 public bool GetAppEnabled(ProjectApp projectApp)
 {
     return(projectApp switch
     {
         ServerApp => ServerAppEnabled,
         CommApp => CommAppEnabled,
         WebApp => WebAppEnabled,
         _ => false
     });
示例#3
0
        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public FrmRegistration(IAdminContext adminContext, ProjectApp projectApp,
                               string productCode, string productName) : this()
        {
            this.adminContext = adminContext ?? throw new ArgumentNullException(nameof(adminContext));
            this.productCode  = productCode ?? throw new ArgumentNullException(nameof(productCode));
            this.projectApp   = projectApp ?? throw new ArgumentNullException(nameof(projectApp));
            regKeyFileName    = Path.Combine(projectApp.ConfigDir, productCode + "_Reg.xml");

            txtProductName.Text = productName;
        }
示例#4
0
        /// <summary>
        /// Downloads the configuration of the specified application.
        /// </summary>
        private void DownloadAppConfig(ProjectApp app)
        {
            transferControl.ThrowIfCancellationRequested();
            transferControl.WriteLine();
            transferControl.WriteMessage(string.Format(AdminPhrases.DownloadAppConfig, app.AppName));

            GetTempFileName(out string tempFileName, out string extractDir);
            agentClient.DownloadConfig(tempFileName, RelativePath.GetTopFolder(app.ServiceApp));
            ExtractArchive(tempFileName, extractDir, downloadOptions.IgnoreRegKeys);
            MergeDirectory(extractDir, instance.InstanceDir);
            progressTracker.TaskIndex++;
        }
示例#5
0
        /// <summary> Returns the type of Office Application that is hosting the VBE. </summary>
        public static IHostApplication HostApplication(this IVBE vbe)
        {
            var host = Path.GetFileName(System.Windows.Forms.Application.ExecutablePath).ToUpperInvariant();

            //This needs the VBE as a ctor argument.
            if (host.Equals("SLDWORKS.EXE"))
            {
                return(new SolidWorksApp(vbe));
            }
            //The rest don't.
            if (HostAppMap.ContainsKey(host))
            {
                return((IHostApplication)Activator.CreateInstance(HostAppMap[host]));
            }

            //Guessing the above will work like 99.9999% of the time for supported applications.
            var project = vbe.ActiveVBProject;

            {
                if (project.IsWrappingNullReference)
                {
                    const int ctlViewHost = 106;

                    var commandBars    = vbe.CommandBars;
                    var hostAppControl = commandBars.FindControl(ControlType.Button, ctlViewHost);
                    {
                        IHostApplication result;
                        if (hostAppControl.IsWrappingNullReference)
                        {
                            result = null;
                        }
                        else
                        {
                            switch (hostAppControl.Caption)
                            {
                            case "Microsoft Excel":
                                result = new ExcelApp();
                                break;

                            case "Microsoft Access":
                                result = new AccessApp();
                                break;

                            case "Microsoft Word":
                                result = new WordApp();
                                break;

                            case "Microsoft PowerPoint":
                                result = new PowerPointApp(vbe);
                                break;

                            case "Microsoft Outlook":
                                result = new OutlookApp();
                                break;

                            case "Microsoft Project":
                                result = new ProjectApp();
                                break;

                            case "Microsoft Publisher":
                                result = new PublisherApp();
                                break;

                            case "Microsoft Visio":
                                result = new VisioApp();
                                break;

                            case "AutoCAD":
                                result = new AutoCADApp();
                                break;

                            case "CorelDRAW":
                                result = new CorelDRAWApp();
                                break;

                            case "SolidWorks":
                                result = new SolidWorksApp(vbe);
                                break;

                            default:
                                result = null;
                                break;
                            }
                        }

                        return(result);
                    }
                }

                var references = project.References;
                {
                    foreach (var reference in references.Where(reference => (reference.IsBuiltIn && reference.Name != "VBA") || (reference.Name == "AutoCAD")))
                    {
                        switch (reference.Name)
                        {
                        case "Excel":
                            return(new ExcelApp(vbe));

                        case "Access":
                            return(new AccessApp());

                        case "Word":
                            return(new WordApp(vbe));

                        case "PowerPoint":
                            return(new PowerPointApp(vbe));

                        case "Outlook":
                            return(new OutlookApp());

                        case "MSProject":
                            return(new ProjectApp());

                        case "Publisher":
                            return(new PublisherApp());

                        case "Visio":
                            return(new VisioApp());

                        case "AutoCAD":
                            return(new AutoCADApp());

                        case "CorelDRAW":
                            return(new CorelDRAWApp(vbe));

                        case "SolidWorks":
                            return(new SolidWorksApp(vbe));
                        }
                    }
                }
            }

            return(null);
        }