Esempio n. 1
0
        public bool Execute(Controller controller)
        {
            _Progress    = 0.0f;
            _RunningTool = null;

            if (EmmeToolsToRun.Count == 0)
            {
                return(true);
            }

            var mc = controller as ModellerController;

            if (mc == null)
            {
                throw new XTMFRuntimeException(this, "Controller is not a ModellerController!");
            }

            float numberOfTasks = AttributesToCreate.Count + 1;

            bool[] createdAttributes = new bool[AttributesToCreate.Count];

            /*
             * def __call__(self, xtmf_ScenarioNumber, xtmf_AttributeId, xtmf_AttributeDomain,
             *   xtmf_AttributeDefault, xtmf_DeleteFlag):
             */

            try
            {
                for (int i = 0; i < createdAttributes.Length; i++)
                {
                    var attData = AttributesToCreate[i];
                    var args    = string.Join(" ", ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, false, ResetToDefault);
                    createdAttributes[i] = mc.Run(this, ToolName, args);
                    // ReSharper disable once PossibleLossOfFraction
                    _Progress = i / createdAttributes.Length / numberOfTasks;
                }
                _Progress = 1.0f / numberOfTasks;

                foreach (var tool in EmmeToolsToRun)
                {
                    tool.Execute(mc);
                    _Progress += 1.0f / numberOfTasks;
                }
            }
            finally
            {
                if (DeleteFlag)
                {
                    for (int i = 0; i < createdAttributes.Length; i++)
                    {
                        if (createdAttributes[i])
                        {
                            var attData = AttributesToCreate[i];
                            var args    = string.Join(" ", ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, true, ResetToDefault);
                            mc.Run(this, ToolName, args);
                        }
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        public bool Execute(Controller controller)
        {
            this._progress    = 0.0f;
            this._RunningTool = null;

            if (this.EmmeToolsToRun.Count == 0)
            {
                return(true);
            }

            var mc = controller as ModellerController;

            if (mc == null)
            {
                throw new XTMFRuntimeException("Controller is not a ModellerController!");
            }

            float numberOfTasks = (float)(this.AttributesToCreate.Count + 1);

            bool[] createdAttributes = new bool[this.AttributesToCreate.Count];

            /*
             * def __call__(self, xtmf_ScenarioNumber, xtmf_AttributeId, xtmf_AttributeDomain,
             *   xtmf_AttributeDefault, xtmf_DeleteFlag):
             */

            try
            {
                for (int i = 0; i < createdAttributes.Length; i++)
                {
                    var attData = this.AttributesToCreate[i];
                    var args    = string.Join(" ", this.ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, false);
                    createdAttributes[i] = mc.Run(_ToolName, args);
                    this._progress       = (float)(i / createdAttributes.Length / numberOfTasks);
                }
                this._progress = 1.0f / numberOfTasks;

                foreach (var tool in this.EmmeToolsToRun)
                {
                    tool.Execute(mc);
                    this._progress += 1.0f / numberOfTasks;
                }
            }
            finally
            {
                if (this.DeleteFlag)
                {
                    for (int i = 0; i < createdAttributes.Length; i++)
                    {
                        if (createdAttributes[i])
                        {
                            var attData = this.AttributesToCreate[i];
                            var args    = string.Join(" ", this.ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, true);
                            mc.Run(_ToolName, args);
                        }
                    }
                }
            }

            return(true);
        }
        public bool Execute(Controller controller)
        {
            this._progress = 0.0f;
            this._RunningTool = null;

            if (this.EmmeToolsToRun.Count == 0) return true;

            var mc = controller as ModellerController;
            if (mc == null)
                throw new XTMFRuntimeException("Controller is not a ModellerController!");

            float numberOfTasks = (float) (this.AttributesToCreate.Count + 1);
            bool[] createdAttributes = new bool[this.AttributesToCreate.Count];

            /*
            def __call__(self, xtmf_ScenarioNumber, xtmf_AttributeId, xtmf_AttributeDomain,
                 xtmf_AttributeDefault, xtmf_DeleteFlag):
            */

            try
            {
                for (int i = 0; i < createdAttributes.Length; i++)
                {
                    var attData = this.AttributesToCreate[i];
                    var args = string.Join(" ", this.ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, false);
                    createdAttributes[i] = mc.Run(_ToolName, args);
                    this._progress = (float)( i /  createdAttributes.Length / numberOfTasks);
                }
                this._progress = 1.0f / numberOfTasks;

                foreach (var tool in this.EmmeToolsToRun)
                {
                    tool.Execute(mc);
                    this._progress += 1.0f / numberOfTasks;
                }
            }
            finally
            {
                if (this.DeleteFlag)
                {
                    for (int i = 0; i < createdAttributes.Length; i++)
                    {
                        if (createdAttributes[i])
                        {
                            var attData = this.AttributesToCreate[i];
                            var args = string.Join(" ", this.ScenarioNumber, attData.Id, attData.Domain, attData.DefaultValue, true);
                            mc.Run(_ToolName, args);
                        }
                    }
                }
            }

            return true;
        }