Пример #1
0
        public void DeactivatePlugin(string pluginName)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new DeactivatePluginDelegate(this.DeactivatePlugin), new object[] { pluginName });
                return;
            }

            TabPage tabPage;
            int     pluginRowDGV = this.minaryMain.MinaryTaskFacade.GetPluginDgvRowByName(pluginName);

            if (this.minaryMain.UsedPlugins[pluginRowDGV].Active != "1")
            {
                return;
            }

            if ((tabPage = this.minaryMain.PluginHandler.FindTabPageInCatalog(pluginName)) == null)
            {
                throw new Exception("Plugin tab page could not be found");
            }

            // Set new status in the registry (to survive the application stop)
            WinRegistry.SetValue(this.minaryMain.UsedPlugins[pluginRowDGV].PluginName, "state", "off");

            // Set new status in the main GUI DGV
            this.minaryMain.MinaryTaskFacade.DeactivatePlugin(pluginName);
            this.minaryMain.MinaryTabPageHandler.HideTabPage(tabPage.Text);

            // Set new status in the tab page catalog
            this.TabPagesCatalog[pluginName].IsActive = false;
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        public void RestoreLastPluginLoadState()
        {
            foreach (string key in this.TabPagesCatalog.Keys)
            {
                try
                {
                    IPlugin tmpPluginObj       = this.TabPagesCatalog[key].PluginObject;
                    string  currentPluginState = WinRegistry.GetValue(key, "state");

                    if (currentPluginState == null)
                    {
                        LogCons.Inst.Write(LogLevel.Info, $"RestoreLastPluginLoadState(): No former state found for plugin {key}");
                    }
                    else if (currentPluginState.ToLower() == "on")
                    {
                        LogCons.Inst.Write(LogLevel.Info, $"Minary.RestoreLastPluginLoadState(): PluginName:{key} State:on");
                        this.ActivatePlugin(key);
                    }
                    else
                    {
                        LogCons.Inst.Write(LogLevel.Info, $"Minary.RestoreLastPluginLoadState(): PluginName:{key} State:off");
                        this.DeactivatePlugin(key);
                    }
                }
                catch (Exception ex)
                {
                    LogCons.Inst.Write(LogLevel.Error, $"RestoreLastPluginLoadState(): Exception: {ex.Message}\r\n{ex.StackTrace}");
                }
            }
        }
Пример #3
0
        public void StartBackgroundThreads()
        {
            // Start data input thread.
            try
            {
                this.inputProcessorHandler.StartInputProcessing();
            }
            catch (Exception ex)
            {
                var message = $"An error occurred while starting the input processor NamedPipe : {ex.Message}" +
                              "\r\n\r\nAborting Minary now.";
                MessageDialog.Inst.ShowError(string.Empty, message, this);
                this.ShutDownMinary();
            }

            // Check if new Minary version is available
            Task.Run(() =>
            {
                string autoupdateStateStr = WinRegistry.GetValue("Updates", "Autoupdate");
                int autoupdateState       = Convert.ToInt32(autoupdateStateStr);

                if (autoupdateState > 0)
                {
                    Updates.Presentation.FormCheckNewVersion newVersionCheck = new Updates.Presentation.FormCheckNewVersion();
                    newVersionCheck.ShowDialog();
                }
            });
        }
Пример #4
0
        public bool RemoveIniFromRegister()
        {
            WinRegistry ureg   = new WinRegistry();
            bool        result = ureg.DeleteKey("attempts") &&
                                 ureg.DeleteKey("proxy") &&
                                 ureg.DeleteKey("host") &&
                                 ureg.DeleteKey("port") &&
                                 ureg.DeleteKey("defaultAuth") &&
                                 ureg.DeleteKey("domain") &&
                                 ureg.DeleteKey("user") &&
                                 ureg.DeleteKey("password") &&
                                 ureg.DeleteKey("mode") &&
                                 ureg.DeleteKey("locallog") &&
                                 ureg.DeleteKey("clock") &&
                                 ureg.DeleteKey("autodir") &&
                                 ureg.DeleteKey("movefile") &&
                                 ureg.DeleteKey("moveafter") &&
                                 ureg.DeleteKey("target") &&
                                 ureg.DeleteKey("procdir") &&
                                 ureg.DeleteKey("interval") &&
                                 ureg.DeleteKey("wstartup") &&
                                 ureg.DeleteKey("interval") &&
                                 ureg.DeleteKey("imgtype") &&
                                 ureg.DeleteKey("jpgquality") &&
                                 ureg.DeleteKey("legend") &&
                                 ureg.DeleteKey("ntpserver") &&
                                 ureg.DeleteKey("ntpport") &&
                                 ureg.DeleteKey("perscreen") &&
                                 ureg.DeleteKey("signature") &&
                                 ureg.DeleteKey("serialkey") &&
                                 ureg.DeleteKey("customer") &&
                                 ureg.DeleteKey("customerMN") &&
                                 ureg.DeleteKey("customerDueDate") &&
                                 ureg.DeleteKey("wstartup") &&
                                 ureg.DeleteKey("licaddress") &&
                                 ureg.DeleteKey("server") &&
                                 ureg.DeleteKey("serverport") &&
                                 ureg.DeleteKey("clientport");

            if (ureg.KeyExists("customer"))
            {
                ureg.DeleteKey("UdyatTrial");
            }
            if (ureg.KeyExists("UdyatRegister"))
            {
                ureg.DeleteKey("UdyatRegister");
            }
            if (ureg.KeyExists("MacSalt"))
            {
                ureg.DeleteKey("MacSalt");
            }
            if (ureg.KeyExists("customerWord"))
            {
                ureg.DeleteKey("customerWord");
            }
            return(result);
        }
Пример #5
0
        private bool ReadIniInFromRegister()
        {
            WinRegistry ureg = new WinRegistry();

            try
            {
                attempts        = ureg.Read("attempts");
                proxy           = ureg.Read("proxy").ToUpper();
                proxyHost       = ureg.Read("host");
                port            = ureg.Read("port");
                defaultAuth     = ureg.Read("defaultAuth").ToUpper();
                domain          = ureg.Read("domain");
                user            = ureg.Read("user");
                password        = ureg.Read("password");
                modeType        = ureg.Read("mode");
                locallog        = ureg.Read("locallog").ToUpper();
                clock           = ureg.Read("clock");
                autodir         = ureg.Read("autodir").ToUpper();
                movefile        = ureg.Read("movefile").ToUpper();
                moveafter       = ureg.Read("moveafter");
                target          = ureg.Read("target").ToUpper();
                procdir         = Util.AddBackslashInPath(ureg.Read("procdir"));
                interval        = ureg.Read("interval");
                imgtype         = ureg.Read("imgtype");
                jpgquality      = ureg.Read("jpgquality");
                legend          = ureg.Read("legend").ToUpper();
                ntpserver       = ureg.Read("ntpserver");
                ntpport         = ureg.Read("ntpport");
                perscreen       = ureg.Read("perscreen").ToUpper();
                signature       = ureg.Read("signature").ToUpper();
                serialKey       = ureg.Read("serialkey").ToUpper();
                customer        = ureg.Read("customer").ToString();
                customerMN      = ureg.Read("customerMN").ToString();
                customerWord    = ureg.Read("customerWord").ToString();
                customerDueDate = ureg.Read("customerDueDate").ToString();
                wstartup        = ureg.Read("wstartup").ToUpper();
                licaddress      = ureg.Read("licaddress").ToUpper();
                trialLicense    = "false";
                if (ureg.KeyExists("UdyatTrial"))
                {
                    trialLicense = ureg.Read("UdyatTrial");
                }
                serverHost = ureg.Read("server").ToString();
                serverPort = ureg.Read("serverport").ToString();
                clientPort = ureg.Read("clientport").ToString();
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #6
0
        public WelcomeDialog()
        {
            InitializeComponent();

            try
            {
                if (WinRegistry.IsAppInstalled())
                {
                    UI.ShowDialog(this, new UninstallDialog());
                }
            }
            catch (Exception ex)
            {
                Message.Show(ex);
            }
        }
Пример #7
0
        private string GetLastSerialkey()
        {
            WinRegistry ureg = new WinRegistry();

            try
            {
                if (ureg.KeyExists("serialkey"))
                {
                    return(ureg.Read("serialkey"));
                }
            }
            catch
            {
                return("");
            }
            return("");
        }
Пример #8
0
        public static void ImportarMarcacoesTerminal(int Terminal, TextBox edLog)
        {
            Types.Terminal TerminalDados;

            DBApp       db       = new DBApp();
            WinRegistry Registro = new WinRegistry("Assecont", "Asseponto4");

            db.getDadosTerminal(Terminal, out TerminalDados);

            Rede rede = new Rede(TerminalDados.IP, edLog);

            string    Arquivo   = Folders.folderMarcacoes(TerminalDados.Descricao) + String.Format("{0:yyyy MM dd hhmm}", DateTime.Now) + ".txt";
            Marcacoes marcacoes = new Marcacoes(Arquivo);

            if (rede.Gertec_ImportarMarcacoes(Terminal, TerminalDados.Descricao, marcacoes))
            {
                Utilitarios.setArquivoImportacao(Registro, Arquivo);
                db.ProcessarMarcacoes(TerminalDados.Grupo, marcacoes, rede.log);
            }
        }
Пример #9
0
        // Gets the latest info of the specified state for the current game from the registry
        private bool UpdateGameState(SteamGameState gameState)
        {
            int? statusValue = WinRegistry.GetValueAsInt(_registryLocation, gameState.ToString());
            bool isValid     = statusValue.HasValue && statusValue.Value == 1;

            if (isValid)
            {
                _gameStates |= gameState;
                Console.WriteLine("Game is " + gameState.ToString());
            }
            // else status key in registry is either invalid or false
            else
            {
                // Clears this bit flag from the status
                _gameStates &= ~gameState;
                Console.WriteLine("Game is NOT " + gameState.ToString());
            }

            return(isValid);
        }
Пример #10
0
        private bool IsIniInRegister()
        {
            WinRegistry ureg = new WinRegistry();

            return(ureg.KeyExists("attempts") &&
                   ureg.KeyExists("proxy") &&
                   ureg.KeyExists("host") &&
                   ureg.KeyExists("port") &&
                   ureg.KeyExists("defaultAuth") &&
                   ureg.KeyExists("domain") &&
                   ureg.KeyExists("user") &&
                   ureg.KeyExists("password") &&
                   ureg.KeyExists("mode") &&
                   ureg.KeyExists("locallog") &&
                   ureg.KeyExists("clock") &&
                   ureg.KeyExists("autodir") &&
                   ureg.KeyExists("movefile") &&
                   ureg.KeyExists("moveafter") &&
                   ureg.KeyExists("target") &&
                   ureg.KeyExists("procdir") &&
                   ureg.KeyExists("interval") &&
                   ureg.KeyExists("wstartup") &&
                   ureg.KeyExists("interval") &&
                   ureg.KeyExists("imgtype") &&
                   ureg.KeyExists("jpgquality") &&
                   ureg.KeyExists("legend") &&
                   ureg.KeyExists("ntpserver") &&
                   ureg.KeyExists("ntpport") &&
                   ureg.KeyExists("perscreen") &&
                   ureg.KeyExists("signature") &&
                   ureg.KeyExists("serialkey") &&
                   //ureg.KeyExists("customer") &&
                   //ureg.KeyExists("customerMN") &&
                   //ureg.KeyExists("customerDueDate") &&
                   ureg.KeyExists("wstartup") &&
                   ureg.KeyExists("licaddress") &&
                   ureg.KeyExists("server") &&
                   ureg.KeyExists("serverport") &&
                   ureg.KeyExists("clientport"));
        }
Пример #11
0
        public void SaveIniInWinRegister()
        {
            WinRegistry ureg = new WinRegistry();

            ureg.Write("attempts", attempts);
            ureg.Write("proxy", proxy);
            ureg.Write("host", proxyHost);
            ureg.Write("port", port);
            ureg.Write("defaultAuth", defaultAuth);
            ureg.Write("domain", domain);
            ureg.Write("user", user);
            ureg.Write("password", password);
            ureg.Write("mode", modeType);
            ureg.Write("locallog", locallog);
            ureg.Write("clock", clock);
            ureg.Write("autodir", autodir);
            ureg.Write("movefile", movefile);
            ureg.Write("moveafter", moveafter);
            ureg.Write("target", target);
            ureg.Write("procdir", procdir);
            ureg.Write("interval", interval);
            ureg.Write("imgtype", imgtype);
            ureg.Write("jpgquality", imgtype);
            ureg.Write("legend", legend);
            ureg.Write("ntpserver", ntpserver);
            ureg.Write("ntpport", ntpport);
            ureg.Write("perscreen", perscreen);
            ureg.Write("signature", signature);
            ureg.Write("serialkey", serialKey);
            ureg.Write("customer", customer);
            ureg.Write("customerMN", customerMN);
            ureg.Write("customerDueDate", customerDueDate);
            ureg.Write("wstartup", wstartup);
            ureg.Write("licaddress", licaddress);
            ureg.Write("server", licaddress);
            ureg.Write("serverport", licaddress);
            ureg.Write("clientport", licaddress);
        }
        /// <summary>
        /// A handler to backgroundWorker.RunWorkerAsync
        /// </summary>
        /// <param name="sender">not used</param>
        /// <param name="e">the arguments </param>
        private void BackgroundWorker_DoWork(object sender,
                                             System.ComponentModel.DoWorkEventArgs e)
        {
            try
            {
                BackgroundWorker worker = sender as BackgroundWorker;
                // exceptions are catched by BackgroundWorker_RunWorkerCompleted


                this.backgroundWorker.ReportProgress(33, "Copying files...");
                Files.Copy();
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                this.backgroundWorker.ReportProgress(66, "Running SQL script...");
                Database.Create();
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                this.backgroundWorker.ReportProgress(100, "Replacing config...");
                Config.ReplaceAll();

                WinRegistry.Register();
            }
            catch (Exception ex)
            {
                e.Cancel      = true;
                lastException = ex;
                return;
            }
        }
Пример #13
0
        public void ActivatePlugin(string pluginName)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new ActivatePluginDelegate(this.ActivatePlugin), new object[] { pluginName });
                return;
            }

            TabPage tabPage;
            int     pluginRowDgv = this.minaryMain.MinaryTaskFacade.GetPluginDgvRowByName(pluginName);

            if (pluginRowDgv < 0)
            {
                throw new Exception($"The plugin \"{pluginName}\" does not exist");
            }

            if (this.minaryMain.UsedPlugins[pluginRowDgv].Active != "0")
            {
                return;
            }

            if ((tabPage = this.minaryMain.PluginHandler.FindTabPageInCatalog(pluginName)) == null)
            {
                throw new Exception($"The plugin tab page \"{pluginName}\" could not be found");
            }

            // Set new status in the registry (to survive the application stop)
            WinRegistry.SetValue(pluginName, "state", "on");

            // Set new status in the main GUI DGV
            this.minaryMain.MinaryTaskFacade.ActivatePlugin(pluginName);
            this.minaryMain.MinaryTabPageHandler.ShowTabPage(tabPage.Text);

            // Set new status in the tab page catalog
            this.TabPagesCatalog[pluginName].IsActive = true;
        }
Пример #14
0
        /// <summary>
        /// Lê o arquivo .INI
        /// </summary>
        public bool ReadIniFile()
        {
            // Abre o arquivo de configuração (se existir)
            INIFile iniFile = new INIFile(AppDomain.CurrentDomain.BaseDirectory + INIFILE_NAME);

            try
            {
                // CONNECTION
                attempts    = iniFile.Read("CONNECTION", "attempts").ToUpper();
                proxy       = iniFile.Read("CONNECTION", "proxy").ToUpper();
                proxyHost   = iniFile.Read("CONNECTION", "host");
                port        = iniFile.Read("CONNECTION", "port");
                defaultAuth = iniFile.Read("CONNECTION", "defaultAuth").ToUpper();
                domain      = iniFile.Read("CONNECTION", "domain");
                user        = iniFile.Read("CONNECTION", "user");
                password    = iniFile.Read("CONNECTION", "password");
                // EXECUTION
                modeType  = iniFile.Read("EXECUTION", "mode");
                locallog  = iniFile.Read("EXECUTION", "locallog").ToUpper();
                clock     = iniFile.Read("EXECUTION", "clock");
                autodir   = iniFile.Read("EXECUTION", "autodir").ToUpper();
                movefile  = iniFile.Read("EXECUTION", "movefile").ToUpper();
                moveafter = iniFile.Read("EXECUTION", "moveafter");
                target    = iniFile.Read("EXECUTION", "target").ToUpper();
                procdir   = Util.AddBackslashInPath(iniFile.Read("EXECUTION", "procdir"));
                wstartup  = iniFile.Read("EXECUTION", "wstartup").ToUpper();
                // CAPTURE
                interval   = iniFile.Read("CAPTURE", "interval");
                imgtype    = iniFile.Read("CAPTURE", "imgtype");
                jpgquality = iniFile.Read("CAPTURE", "jpgquality");
                legend     = iniFile.Read("CAPTURE", "legend").ToUpper();
                ntpserver  = iniFile.Read("CAPTURE", "ntpserver");
                ntpport    = iniFile.Read("CAPTURE", "ntpport");
                perscreen  = iniFile.Read("CAPTURE", "perscreen").ToUpper();
                signature  = iniFile.Read("CAPTURE", "signature").ToUpper();
                // COSTUMER
                serialKey  = iniFile.Read("CUSTOMER", "serialkey").ToString();
                licaddress = iniFile.Read("CUSTOMER", "licaddress").ToString();
                // P2P
                serverHost = iniFile.Read("P2P", "server");
                serverPort = iniFile.Read("P2P", "serverport");
                clientPort = iniFile.Read("P2P", "clientport");
                // Variáveis que são gravadas somente ao ativar uma licença
                WinRegistry ureg = new WinRegistry();
                if (ureg.KeyExists("customer"))
                {
                    customer = ureg.Read("customer").ToString();
                }
                if (ureg.KeyExists("customerMN"))
                {
                    customerMN = ureg.Read("customerMN").ToString();
                }
                if (ureg.KeyExists("customerWord"))
                {
                    customerWord = ureg.Read("customerWord").ToString();
                }
                if (ureg.KeyExists("UdyatTrial"))
                {
                    trialLicense = ureg.Read("UdyatTrial").ToString();
                }
                return(true);
            }
            catch
            {
                return(false);
            }
        }
Пример #15
0
 public static string getArquivoImportacao(WinRegistry Registro)
 {
     return(Registro.getValue(Consts.TERMINALNOME, "Ultimo arquivo importado", ""));
 }
Пример #16
0
 public static void setArquivoImportacao(WinRegistry Registro, string value)
 {
     Registro.setValue(Consts.TERMINALNOME, "Ultimo arquivo importado", value);
 }