コード例 #1
0
        private System.Collections.IEnumerator CRVersionCheck()
        {
            WWW wwwVersionCheck;

            //set initial stuff and save it
            VersionCheckRunning           = true;
            this.VersionCheckResult       = "Unknown - check again later";
            this.VersionCheckDate_Attempt = DateTime.Now;
            this.Save();

            //now do the download
            Log.dbg("Reading version from Web");
            wwwVersionCheck = new WWW(VersionCheckURL);
            yield return(wwwVersionCheck);

            if (wwwVersionCheck.error == null)
            {
                CRVersionCheck_Completed(wwwVersionCheck);
            }
            else
            {
                Log.dbg("Version Download failed:{0}", wwwVersionCheck.error);
            }
            VersionCheckRunning = false;
        }
コード例 #2
0
        /// <summary>
        /// Loads the object from the Data.ConfigNode structure in the previously supplied file
        /// </summary>
        /// <returns>Succes of Load</returns>
        public Boolean Load()
        {
            Log.dbg("Loading Data.ConfigNode");

            Boolean blnReturn = false;

            try
            {
                if (FileExists)
                {
                    //Load the file into a config node
                    this.configNode.Load();
                    //plug it in to the object
                    ConfigNode.LoadObjectFromConfig(this, this.configNode.Node);
                    blnReturn = true;
                }
                else
                {
                    Log.warn("File could not be found to load({0})", this.configNode.Path);
                    blnReturn = false;
                }
            }
            catch (Exception ex)
            {
                Log.error(ex, "Failed to Load Data.ConfigNode from file({0})", this.configNode.Path);
                string emergencyFilename = String.Format("{0}.err-{1}", this.configNode.Path, string.Format("ddMMyyyy-HHmmss", DateTime.Now));
                Log.warn("Storing old config - {0}", emergencyFilename);
                System.IO.File.Copy(this.configNode.Path, emergencyFilename, true);
                blnReturn = false;
            }
            return(blnReturn);
        }
コード例 #3
0
        /// <summary>
        /// Saves the object to a Data.ConfigNode structure in the previously supplied file
        /// </summary>
        /// <returns>Succes of Save</returns>
        public Boolean Save()
        {
            Log.dbg("Saving Data.ConfigNode");

            Boolean blnReturn = false;

            try
            {
                //Encode the current object
                ConfigNode cnToSave = this.AsConfigNode;

                //Wrap it in a node with a name of the class
                ConfigNode cnSaveWrapper = new ConfigNode(this.GetType().Name);
                cnSaveWrapper.AddNode(cnToSave);

                //Save it to the file
                this.configNode.Save(cnSaveWrapper);
                blnReturn = true;
            }
            catch (Exception ex)
            {
                Log.error(ex, "Failed to Save ConfigNode to file({0})", this.configNode.Path);
                blnReturn = false;
            }
            return(blnReturn);
        }
コード例 #4
0
 /// <summary>
 /// Starts the RepeatingWorker Function and sets the TimesPerSec variable
 /// </summary>
 /// <param name="TimesPerSec">How many times a second should the RepeatingWorker Function be run</param>
 /// <returns>The RunningState of the RepeatinWorker Function</returns>
 internal Boolean StartRepeatingWorker(Int32 TimesPerSec)
 {
     Log.dbg("Starting the repeating function");
     //Stop it if its running
     StopRepeatingWorker();
     //Set the new value
     SetRepeatTimesPerSecond(TimesPerSec);
     //Start it and return the result
     return(StartRepeatingWorker());
 }
コード例 #5
0
        private Boolean AddMissingSoundConfig(String Name, params KACAlarm.AlarmTypeEnum[] Types)
        {
            if (!AlarmSounds.Any(s => s.Name == Name))
            {
                Log.detail("Initing Sound Config for:{0}", Name);
                AlarmSounds.Add(new AlarmSound(Name, Types));
                return(true);
            }

            return(false);
        }
コード例 #6
0
        /// <summary>
        /// Does some logic to see if a check is needed, and returns true if there is a different version
        /// </summary>
        /// <param name="ForceCheck">Ignore all logic and simply do a check</param>
        /// <returns></returns>
        public Boolean VersionCheck(MonoBehaviour parent, Boolean ForceCheck)
        {
            Boolean blnReturn  = false;
            Boolean blnDoCheck = false;

            try
            {
                if (!VersionCheckRunning)
                {
                    if (ForceCheck)
                    {
                        blnDoCheck = true;
                        Log.dbg("Starting Version Check-Forced");
                    }
                    //else if (this.VersionWeb == "")
                    //{
                    //    blnDoCheck = true;
                    //    Log.dbg("Starting Version Check-No current web version stored");
                    //}
                    else if (this.VersionCheckDate_Attempt < DateTime.Now.AddYears(-9))
                    {
                        blnDoCheck = true;
                        Log.dbg("Starting Version Check-No current date stored");
                    }
                    else if (this.VersionCheckDate_Attempt.Date != DateTime.Now.Date)
                    {
                        blnDoCheck = true;
                        Log.dbg("Starting Version Check-stored date is not today");
                    }
                    else
                    {
                        Log.dbg("Skipping version check");
                    }

                    if (blnDoCheck)
                    {
                        parent.StartCoroutine(CRVersionCheck());
                    }
                }
                else
                {
                    Log.dbg("Starting Version Check-version check already running");
                }

                blnReturn = true;
            }
            catch (Exception ex)
            {
                Log.dbg("Failed to run the update test");
                Log.dbg(ex.Message);
            }
            return(blnReturn);
        }
コード例 #7
0
 /// <summary>
 /// Stop the RepeatingWorkerFunction
 /// </summary>
 /// <returns>The RunningState of the RepeatinWorker Function</returns>
 internal Boolean StopRepeatingWorker()
 {
     try
     {
         Log.dbg("Cancelling the repeating function");
         this.CancelInvoke("RepeatingWorkerWrapper");
         _RepeatRunning = false;
     }
     catch (Exception e)
     {
         Log.error(e, "Unable to cancel the repeating function");
         //throw;
     }
     return(_RepeatRunning);
 }
コード例 #8
0
 /// <summary>
 /// Starts the Repeating worker
 /// </summary>
 /// <returns>The RunningState of the RepeatinWorker Function</returns>
 internal Boolean StartRepeatingWorker()
 {
     try
     {
         Log.dbg("Invoking the repeating function");
         this.InvokeRepeating("RepeatingWorkerWrapper", _RepeatInitialWait, RepeatingWorkerRate);
         _RepeatRunning = true;
     }
     catch (Exception e)
     {
         Log.error(e, "Unable to invoke the repeating function");
         //throw;
     }
     return(_RepeatRunning);
 }
コード例 #9
0
        void CRVersionCheck_Completed(WWW wwwVersionCheck)
        {
            try
            {
                //get the response from the variable and work with it
                //Parse it for the version String
                String strFile = wwwVersionCheck.text;
                Log.dbg("Response Length:" + strFile.Length);
                Log.dbg("File:{0}", strFile);

                Match matchVersion;
                matchVersion = Regex.Match(strFile, "(?<=\\|LATESTVERSION\\|).+(?=\\|LATESTVERSION\\|)", System.Text.RegularExpressions.RegexOptions.Singleline);
                Log.dbg("Got Version '" + matchVersion.ToString() + "'");

                String strVersionWeb = matchVersion.ToString();
                if (strVersionWeb != "")
                {
                    this.VersionCheckResult       = "Success";
                    this.VersionCheckDate_Success = DateTime.Now;
                    this.VersionWeb = strVersionWeb;
                }
                else
                {
                    this.VersionCheckResult = "Unable to parse web service";
                }
            }
            catch (Exception ex)
            {
                Log.dbg("Failed to read Version info from web");
                Log.dbg(ex.Message);
            }
            Log.dbg("Version Check result:" + VersionCheckResult);

            this.Save();
            VersionAttentionFlag = VersionAvailable;
        }
コード例 #10
0
 /// <summary>
 /// Extension Function - this will run only once each time the monobehaviour is awakened
 ///
 /// Added this so you can put your GUI initialisation code in here. Running GUI initialisation stuff in Awake/Start will throw an error
 /// </summary>
 internal virtual void OnGUIOnceOnly()
 {
     Log.dbg("Running OnGUI OnceOnly Code");
 }
コード例 #11
0
 /// <summary>
 /// Unity Help: This function is called when the MonoBehaviour will be destroyed..
 ///
 /// Trigger: Override this for destruction and cleanup code
 ///          See this for info on order of execution: https://docs.unity3d.com/Manual/ExecutionOrder.html
 /// </summary>
 internal virtual void OnDestroy()
 {
     Log.dbg("Destroying MBExtended");
 }
コード例 #12
0
 /// <summary>
 /// Unity: Start is called on the frame when a script is enabled just before any of the Update methods is called the first time.
 ///
 /// Trigger: This is the last thing that happens before the scene starts doing stuff
 ///          See this for info on order of execution: https://docs.unity3d.com/Manual/ExecutionOrder.html
 /// </summary>
 internal virtual void Start()
 {
     Log.dbg("New MBExtended Started");
 }
コード例 #13
0
 internal virtual void OnAwake()
 {
     Log.dbg("New MBExtended Awakened");
 }