public static Boolean ProcessFiles(Scenario sc)
 {
     int counter;
     String prefix;
     foreach (Request req in sc.Requests)
     {
         counter = 1;
         prefix = string.Format("{0}_{1}", sc.Id, req.Id);
         foreach (FileItem f in req.Files)
         {
             try
             {
                 if (f.FilePath == null)
                 {
                     errorMessage += string.Format(Director.Properties.Resources.ExportSkipFileWarning, f.FileName,
                         req.Name, sc.Name);
                     continue;
                 }
                 String newFileName = string.Format("{0}_{1}_{2}", prefix, counter, Path.GetFileName(f.FilePath));
                 String resourceDir = Path.Combine(tmpDirectory.FullName, Export.resourceDirectory);
                 File.Copy(f.FilePath, Path.Combine(resourceDir, newFileName), true);
                 f.FilePath = newFileName;
                 counter++;
             }
             catch (Exception e)
             {
                 errorMessage = Director.Properties.Resources.ExportProcessFilesEx + e.Message;
                 return false;
             }
         }
         // delete all invalid files
         req.Files.RemoveAll(item => item.FilePath == null);
     }
     return true;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="Director.RunWithHeaders"/> class.
        /// </summary>
        /// <param name="_scenario">_scenario.</param>
        public SelectVariables(Scenario _scenario)
        {
            ActiveScenario = _scenario;
            Width = 500;
            Height = 300;
            Title = Director.Properties.Resources.SetVariables;
            Icon = Image.FromResource(DirectorImages.VARIABLES_ICON);

            // Init components
            _initializeComponents ();

            // CLose btns
            Buttons.Add (new DialogButton (Director.Properties.Resources.ButtonRunAndSave, Command.Ok));
            Buttons.Add (new DialogButton (Director.Properties.Resources.ButtonSave, Command.Save));
            Buttons.Add (new DialogButton (Director.Properties.Resources.ButtonStorno, Command.Cancel));
        }
        /// <summary>
        /// Create header list.
        /// </summary>
        public HeaderList(List<Header> headers, Scenario sc = null)
        {
            // Set headers
            Headers = headers;

            // Expand
            ExpandHorizontal = true;
            ExpandVertical = true;

            // Margins
            Margin = 10;

            // Scenario
            ActiveScenario = sc;

            // Header list items
            HeaderListItems = new List<HeaderListItem>();

            // Prepare
            _initializeComponents();

            // Refresh headers
            RefreshHeaderList();
        }
        /// <summary>
        /// Set scenario and other properties.
        /// </summary>
        /// <param name="_scenario"></param>
        public void SetScenario(Scenario _scenario)
        {
            ActiveScenario = _scenario;

            // Skip Change Event
            ScenarioName.Changed -= ScenarioName_Changed;
            ScenarioName.Text = _scenario.Name;
            ScenarioName.Changed += ScenarioName_Changed;

            // Runing frequency
            FrequencyRunning.SelectedIndex = ActiveScenario.RunningFrequency;

            // Time dealay time
            TimeDelay.Text = ActiveScenario.TimeAfterPrevious + "";

            // Running type
            PeriodicityRunning.Active = ActiveScenario.PeriodicityRunning;
            ChangeFrequencyOption(null, null);

            // Markdown summary
            RefreshScenarioSummary();
        }
Exemple #5
0
 /// <summary>
 /// Remove scenario item.
 /// </summary>
 /// <param name="sc">Sc.</param>
 public void RemoveScenario(Scenario sc)
 {
     Scenarios.Remove(sc);
 }
Exemple #6
0
        /// <summary>
        /// Switch scenario with scenario before.
        /// </summary>
        public Scenario MoveScenarioUp(Scenario _scenario)
        {
            // Get max position ID
            int _minPosition = Scenarios.Min(n => n.Position);

            if (_minPosition == _scenario.Position)
                return null;

            // Find scenario after
            for (int i = _scenario.Position - 1; i >= _minPosition; i--)
            {
                var _newScenario = Scenarios.First(n => n.Position == i);
                if (_newScenario != null)
                {
                    _newScenario.Position = _scenario.Position;
                    _scenario.Position = i;
                    return _newScenario;
                }
            }
            return null;
        }
Exemple #7
0
        /// <summary>
        /// Switch scenario with scenario after.
        /// </summary>
        public Scenario MoveScenarioDown(Scenario _scenario)
        {
            // Get max position ID
            int _maxPosition = Scenarios.Max(n => n.Position);

            if (_maxPosition == _scenario.Position)
                return null;

            // Find scenario after
            for (int i = _scenario.Position + 1; i <= _maxPosition; i++)
            {
                var _newScenario = Scenarios.First(n => n.Position == i);
                if (_newScenario != null)
                {
                    _newScenario.Position = _scenario.Position;
                    _scenario.Position = i;
                    return _newScenario;
                }
            }
            return null;
        }
Exemple #8
0
        /// <summary>
        /// Create new next scenario!
        /// </summary>
        public Scenario CreateNewScenario()
        {
            // Id and position is actual scenario list size
            int _scenarioId = 1, _position = 1;

            // There are some members of scenario in list
            if (Scenarios.Count > 0)
            {
                _scenarioId = Scenarios.Max(x => x.Id) + 1;
                _position = Scenarios.Max(x => x.Position) + 1;
            }

            // Create a new one
            var newScenario = new Scenario(_scenarioId, _position, Director.Properties.Resources.NewScenarioName)
            {
                ParentServer = this
            };

            // Add to list
            Scenarios.Add(newScenario);

            // Return scenario
            return newScenario;
        }
        /// <summary>
        /// Switch scenario ServerStore objects.
        /// </summary>
        private void SwitchScenarioObjects(Scenario _scenario, Scenario _newScenario)
        {
            ServerStore.GetNavigatorAt(_scenario.TreePosition).SetValue(ColumnName, _newScenario.Name);
            ServerStore.GetNavigatorAt(_newScenario.TreePosition).SetValue(ColumnName, _scenario.Name);

            // Switch objects
            ServerStore.GetNavigatorAt(_scenario.TreePosition).SetValue(ColumnType, _newScenario);
            ServerStore.GetNavigatorAt(_newScenario.TreePosition).SetValue(ColumnType, _scenario);

            // Switch positions
            TreePosition tmpTP = _scenario.TreePosition;
            _scenario.TreePosition = _newScenario.TreePosition;
            _newScenario.TreePosition = tmpTP;

            // Switch childrens
            ServerStore.GetNavigatorAt(_scenario.TreePosition).RemoveChildren();
            ServerStore.GetNavigatorAt(_newScenario.TreePosition).RemoveChildren();

            // Create childrens again
            foreach (Request s in _scenario.Requests.OrderBy(n => n.Position))
            {
                s.TreePosition = CreateTreeItem(_scenario.TreePosition, s.Name, RequestImage, s);
            }

            foreach (Request s in _newScenario.Requests.OrderBy(n => n.Position))
            {
                s.TreePosition = CreateTreeItem(_newScenario.TreePosition, s.Name, RequestImage, s);
            }

            // Refresh
            UpdateControlView(null, null);
        }
 public static void ProcessFiles(Scenario sc)
 {
     String resourceDir = Path.Combine(tmpDirectory.FullName, Export.resourceDirectory);
     foreach (Request req in sc.Requests)
     {
         foreach (FileItem f in req.Files)
         {
             //for now use the old name
             //var groups = Regex.Match(f.FilePath, @"(\d+)_(\d+)_(\d+)_(.*)").Groups;
             //String newFileName = groups[4].Value;
             String newFileName = f.FilePath;
             f.FilePath = Path.Combine(resourceDir, newFileName);
         }
     }
 }