Esempio n. 1
0
    public void StartUp()
    {
        health = GetComponent <Health>();
        if (health == null)
        {
            Debug.LogError("Could not find Health component", this);
        }
        debugHolder     = ScriptableObject.CreateInstance <PersonAIDebugHolder>();
        levelGeneration = FindObjectOfType <LevelGeneration>();

        animatorController   = GetComponent <AnimationCommandController>();
        traversalGraphHolder = FindObjectOfType <TraversalGraphHolder>();
        traversalAStar       = new TraversalAStarNavigation(traversalGraphHolder);

        personalTasks = ScriptableObject.CreateInstance <TaskListHolder>();
        currentState  = GoToState(startingState);

        FindCurrentRoom();
    }
Esempio n. 2
0
        // Start the service.
        protected override void OnStart(string[] args)
        {
            Log("OnStart", "Starting...");

            if (ReportsSchedulerWcf.Singleton != null)
            {
                ReportsSchedulerWcf.Singleton.Paused = false;
            }

            // set service status to start pending:
            IntPtr handle = this.ServiceHandle;

            _serviceStatus.currentState = SERVICE_STATE.SERVICE_START_PENDING;
            SetServiceStatus(handle, ref _serviceStatus);

            // Get values for arguments passed in from the Services control panel or
            // by the ServiceController class Start(string[]) method.
            Log("OnStart", string.Format("Invoked with {0} command line arguments.", args.Length));
            for (int i = 0; i < args.Length; ++i)
            {
                Log("OnStart", string.Format("Command line argument {0}: \"{1}\"", i, args[i]));
            }

            // Get arguments from the ImagePath string value for the service's registry
            // key (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\C1Reports_Scheduler).
            string[] imagePathArgs = Environment.GetCommandLineArgs();
            Log("OnStart", string.Format("Invoked with {0} ImagePath arguments.", imagePathArgs.Length));
            for (int i = 0; i < imagePathArgs.Length; ++i)
            {
                Log("OnStart", string.Format("ImagePath argument {0}: \"{1}\"", i, imagePathArgs[i]));
            }

            // Get log flags from registry:
            try
            {
                using (RegistryKey key = Registry.LocalMachine.OpenSubKey(Constants.RegKey_Root))
                {
                    AltUtil.LogTasks         = (int)key.GetValue(Constants.RegKey_LogTasks) != 0;
                    AltUtil.LogActions       = (int)key.GetValue(Constants.RegKey_LogActions) != 0;
                    AltUtil.LogProgramOutput = (int)key.GetValue(Constants.RegKey_LogProgramOutput) != 0;
                }
            }
            catch (Exception ex)
            {
                Log("OnStart", string.Format("ERROR: Could not get log values from registry: {0}", ex.Message));
            }
            Log("OnStart", string.Format("Logging scheduled tasks is {0}.", AltUtil.LogTasks ? "ON" : "OFF"));
            Log("OnStart", string.Format("Logging scheduled tasks' actions is {0}.", AltUtil.LogActions ? "ON" : "OFF"));
            Log("OnStart", string.Format("Logging scheduled \"external program\" type tasks' program output is {0}.", AltUtil.LogProgramOutput ? "ON" : "OFF"));

            // reset .c1rsconf path:
            _c1rsconfPath = null;

            // get .c1rsconf file path from registry:
            using (RegistryKey key = Registry.LocalMachine.OpenSubKey(Constants.RegKey_Root))
                _c1rsconfPath = key.GetValue(Constants.RegKey_C1rsconfFilePath) as string;

            // check whether .c1rsconf file was specified in ImagePath,
            // ImagePath overrides registry value:
            if (imagePathArgs.Length >= 2)
            {
                _c1rsconfPath = imagePathArgs[1];
            }

            // check whether .c1rsconf file was specified on command line,
            // command line overrides all:
            if (args.Length >= 1)
            {
                _c1rsconfPath = args[0];
            }

            // if c1rsconf file exists, load tasks from it:
            if (File.Exists(_c1rsconfPath))
            {
                // loading may take time... try to calc it?
                this.RequestAdditionalTime(4000);

                try
                {
                    Log("OnStart", string.Format("Loading task list from: {0}", _c1rsconfPath));
                    _tasks = (TaskListHolderServer)TaskListHolder.Load(_c1rsconfPath);
                }
                catch (Exception ex)
                {
                    Log("OnStart", string.Format("Error loading task list: {0}", ex.Message));
                    _tasks = new TaskListHolderServer();
                }
            }

            // log loaded tasks:
            foreach (C1ReportsScheduler.TaskBase task in _tasks.Tasks)
            {
                // in service, ignore Paused prop - tasks are paused together when service is paused,
                // resumed accordingly
                task.Schedule.Paused = false;
                Log("TASK", string.Format("STARTED: Kind={0}, Name={1}, File={2}.", task.ReportKind, task.ReportName, task.FileName));
            }

            StartWcf();

            // set service status to running:
            _serviceStatus.currentState = SERVICE_STATE.SERVICE_RUNNING;
            SetServiceStatus(handle, ref _serviceStatus);

            Log("OnStart", "Started.");
        }
 private void OnEnable()
 {
     taskListHolder = (TaskListHolder)target;
     tasks          = serializedObject.FindProperty("tasks");
 }