Esempio n. 1
0
 void Start()
 {
     //finds the required components and assigns them to their respective variables
     rulescript = Camera.main.GetComponent <RuleScript> ();
     btn        = this.gameObject.GetComponent <Button> ();
     //adds a listener to the button to execute TaskOnClick upon pressing
     btn.onClick.AddListener(TaskOnClick);
 }
Esempio n. 2
0
        private bool ExecuteDatabaseScript(GCInterface gcInterface, RuleScript script, bool backup)
        {
            GCError.ClearLastError();

            // validate interface
            if (script == null || script.Type == RuleScriptType.None)
            {
                GCError.SetLastError("Invalid script.");
                return(false);
            }

            string sqlFileName = null;

            if (backup)
            {
                sqlFileName = script.GetBackupFileName();
            }
            else
            {
                sqlFileName = script.FileName;
            }

            try
            {
                sqlFileName = ConfigHelper.GetFullPath(gcInterface.FolderPath + "\\" + sqlFileName);
                if (!File.Exists(sqlFileName))
                {
                    return(true);
                }

                if (!DataBase.OSQLExec(sqlFileName))
                {
                    GCError.SetLastError("Run sql script failed.\r\nOSQL.EXE Path:" + DataBase.OSQLFileName + "\r\nDatabase: " + DataBase.OSQLDatabase + "\r\nSQL File Path:" + sqlFileName);
                    return(false);
                }
            }
            catch (Exception err)
            {
                GCError.SetLastError("Run sql script exception.\r\nOSQL.EXE Path:" + DataBase.OSQLFileName + "\r\nDatabase: " + DataBase.OSQLDatabase + "\r\nSQL File Path:" + sqlFileName);
                GCError.SetLastError(err);
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Handles the <see cref="TextBoxBase.TextChanged"/> event for the "Rule Script" <see
        /// cref="TextBox"/>.</summary>
        /// <param name="sender">
        /// The <see cref="Object"/> where the event handler is attached.</param>
        /// <param name="args">
        /// A <see cref="TextChangedEventArgs"/> object containing event data.</param>
        /// <remarks>
        /// <b>OnRulesChanged</b> copies the current contents of the "Rule Script" text box to the
        /// <see cref="RuleScript.Path"/> of the current <see cref="MasterSection.Rules"/>, and sets
        /// the <see cref="SectionTabItem.DataChanged"/> flag.</remarks>

        private void OnRulesChanged(object sender, TextChangedEventArgs args)
        {
            args.Handled = true;

            // do nothing if rules path unchanged
            RuleScript rules = MasterSection.Instance.Rules;

            if (rules.Path == RulesPathBox.Text)
            {
                return;
            }

            // store new rules path in scenario section
            rules.Path = RulesPathBox.Text;

            // broadcast data changes
            SectionTab.DataChanged = true;
        }
Esempio n. 4
0
        private bool BackupScriptFile(RuleScript scriptFile)
        {
            if (scriptFile == null)
            {
                return(false);
            }
            string oldFilename = Application.StartupPath + "\\" + scriptFile.FileName;
            string newFileName = Application.StartupPath + "\\" + scriptFile.GetBackupFileName();

            if (File.Exists(oldFilename))
            {
                Program.Log.Write("Uninstall script found. " + oldFilename);
                if (File.Exists(newFileName))
                {
                    File.Delete(newFileName);
                }
                File.Copy(oldFilename, newFileName);
                Program.Log.Write("Uninstall script backuped. " + newFileName);
            }
            return(true);
        }
 void Start()
 {
     rulescript = Camera.main.GetComponent <RuleScript> ();
     btn        = this.gameObject.GetComponent <Button> ();
     btn.onClick.AddListener(TaskOnClick);
 }
Esempio n. 6
0
 private bool ExecuteDatabaseScript(GCInterface gcInterface, RuleScript script)
 {
     return(ExecuteDatabaseScript(gcInterface, script, false));
 }