/**************************************************************\ * Display Batch Summary * \**************************************************************/ public void DisplayBatchSummary(Batch batch) { _ProcessHeaderGroupList.Clear(); _ProcessHeaderGroupList = new List<KryptonHeaderGroup>(); this.SummarySplitContainer1.Panel1.Controls.Clear(); // Display the name of the batch KryptonHeader header = new KryptonHeader(); header.Dock = System.Windows.Forms.DockStyle.Top; header.Text = "Batch : " + batch.Get_Name(); header.Values.Description = null; header.Values.Image = null; // Display all batch elements if (batch.Get_BatchElements().Count > 0) { foreach (KeyValuePair<string, Tuple<string, string, string>> element in batch.Get_BatchElements()) { KryptonHeaderGroup headerGroup = new KryptonHeaderGroup(); ButtonSpecHeaderGroup buttonSpecHeaderGroup = new ButtonSpecHeaderGroup(); headerGroup.Dock = System.Windows.Forms.DockStyle.Top; headerGroup.HeaderPositionSecondary = ComponentFactory.Krypton.Toolkit.VisualOrientation.Left; headerGroup.ValuesPrimary.Image = null; headerGroup.HeaderStylePrimary = ComponentFactory.Krypton.Toolkit.HeaderStyle.Secondary; headerGroup.ValuesSecondary.Heading = "Target"; headerGroup.Text = element.Value.Item1; buttonSpecHeaderGroup.Tag = headerGroup; headerGroup.ButtonSpecs.AddRange(new ComponentFactory.Krypton.Toolkit.ButtonSpecHeaderGroup[] { buttonSpecHeaderGroup }); headerGroup.ButtonSpecs[0].Type = ComponentFactory.Krypton.Toolkit.PaletteButtonSpecStyle.RibbonExpand; headerGroup.Size = new System.Drawing.Size(150, 23); KryptonRichTextBox richTextBox = new KryptonRichTextBox(); richTextBox.Dock = System.Windows.Forms.DockStyle.Fill; richTextBox.ReadOnly = true; richTextBox.Text = element.Key + "\n\n FTP : " + element.Value.Item3; headerGroup.Panel.Controls.Add(richTextBox); _ProcessHeaderGroupList.Add(headerGroup); } } else if (batch.Get_BatchElementsMulti().Count > 0) { foreach (KeyValuePair<Tuple<string, string>, List<Tuple<string, string>>> element in batch.Get_BatchElementsMulti()) { KryptonHeaderGroup headerGroup = new KryptonHeaderGroup(); ButtonSpecHeaderGroup buttonSpecHeaderGroup = new ButtonSpecHeaderGroup(); headerGroup.Dock = System.Windows.Forms.DockStyle.Top; headerGroup.HeaderPositionSecondary = ComponentFactory.Krypton.Toolkit.VisualOrientation.Left; headerGroup.ValuesPrimary.Image = null; headerGroup.HeaderStylePrimary = ComponentFactory.Krypton.Toolkit.HeaderStyle.Secondary; headerGroup.ValuesSecondary.Heading = "Target"; headerGroup.Text = element.Value[0].Item1; buttonSpecHeaderGroup.Tag = headerGroup; headerGroup.ButtonSpecs.AddRange(new ComponentFactory.Krypton.Toolkit.ButtonSpecHeaderGroup[] { buttonSpecHeaderGroup }); headerGroup.ButtonSpecs[0].Type = ComponentFactory.Krypton.Toolkit.PaletteButtonSpecStyle.RibbonExpand; headerGroup.Size = new System.Drawing.Size(150, 23); KryptonRichTextBox richTextBox = new KryptonRichTextBox(); richTextBox.Dock = System.Windows.Forms.DockStyle.Fill; richTextBox.ReadOnly = true; richTextBox.AppendText( "FTP : " + element.Key.Item2 + "\n\n"); richTextBox.AppendText("Target path : " + element.Key.Item1 + "\n\n"); richTextBox.AppendText("Configs :\n"); foreach (Tuple<string, string> config in element.Value) richTextBox.AppendText(config.Item1 + "\n"); headerGroup.Panel.Controls.Add(richTextBox); _ProcessHeaderGroupList.Add(headerGroup); } } _ProcessHeaderGroupList.Reverse(); foreach (KryptonHeaderGroup element in _ProcessHeaderGroupList) this.SummarySplitContainer1.Panel1.Controls.Add(element); this.SummarySplitContainer1.Panel1.Controls.Add(header); }
/****************************************************** MULTI MODE *******************************************************/ private void InstanciateBatchMultiGraphical(Batch batch) { TutoLabelMulti.Visible = false; // Set navigator page Navigator.SelectedIndex = 1; // Open creation section if (SplitContainer.Panel2Collapsed) { Form form = (Form)this.Parent; form.Size = new System.Drawing.Size(form.Width + 300, form.Height); SplitContainer.Panel2Collapsed = false; SplitContainer.Panel2.Show(); } else { BatchNameTextBox.Text = ""; BatchNameTextBoxMulti.Text = ""; foreach (BatchElement element in _BatchElements) element.Dispose(); _BatchElements.Clear(); foreach (BatchElementMulti element2 in _BatchElementsMulti) element2.Dispose(); _BatchElementsMulti.Clear(); } // Add graphical elements if (batch.Get_Type().Equals("Multi")) { BatchNameTextBoxMulti.Text = batch.Get_Name(); foreach (KeyValuePair<Tuple<string, string>, List<Tuple<string, string>>> element in batch.Get_BatchElementsMulti()) { BatchElementMulti batchElement = new BatchElementMulti(_RegionsList); batchElement.Set_TargetPathTooltip(element.Key.Item1); batchElement.Set_TargetPath(element.Key.Item1); batchElement.Set_FtpRegion(element.Key.Item2); batchElement.FTPComboBox.Text = element.Key.Item2; for (int i = 0; i < element.Value.Count; i++) { if (i == 0) { batchElement.Config.Text = element.Value[0].Item1; batchElement.Get_ConfigsInfo().Add(element.Value[i].Item1, element.Value[i].Item2); } else { batchElement.TutoLabel.Visible = false; batchElement.Set_IdControls(batchElement.Get_IdControls() + 1); batchElement.SuppressButton.Click += SuppressButton_Click; //////////////// // Add graphics // Label "Config" KryptonLabel configLabel = new KryptonLabel(); configLabel.Text = "Config : "; configLabel.Tag = batchElement.Get_IdControls(); configLabel.Location = new System.Drawing.Point(35, 86 + (batchElement.Get_AdditionalConfigsLabel().Count + 1) * 20); batchElement.GroupBox.Panel.Controls.Add(configLabel); // Label config name Label configNameLabel = new Label(); configNameLabel.AutoSize = true; configNameLabel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); configNameLabel.Text = element.Value[i].Item1; configNameLabel.BackColor = System.Drawing.Color.Transparent; configNameLabel.Font = new System.Drawing.Font("Calibri", 11.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); configNameLabel.Tag = batchElement.Get_IdControls(); ; configNameLabel.Location = new System.Drawing.Point(94, 86 + (batchElement.Get_AdditionalConfigs().Count + 1) * 20); batchElement.GroupBox.Panel.Controls.Add(configNameLabel); // mini suppress button KryptonButton button = new KryptonButton(); button.Tag = batchElement.Get_IdControls(); button.ButtonStyle = ComponentFactory.Krypton.Toolkit.ButtonStyle.LowProfile; button.Location = new System.Drawing.Point(10, 88 + (batchElement.Get_AdditionalConfigs().Count + 1) * 20); button.Size = new System.Drawing.Size(16, 16); button.Values.Image = global::Analytics_V2.Properties.Resources.Delete2; button.Click += batchElement.SuppressConfigElement; batchElement.GroupBox.Panel.Controls.Add(button); batchElement.Get_AdditionalConfigsLabel().Add(configLabel); batchElement.Get_AdditionalConfigs().Add(configNameLabel); batchElement.Get_SuppressButtons().Add(button); // Add config to dictionnary batchElement.Get_ConfigsInfo().Add(element.Value[i].Item1, element.Value[i].Item2); batchElement.Height += 20; } } // Add new element to the UC BatchElementsGroupBoxMulti.Panel.Controls.Add(batchElement); batchElement.Dock = DockStyle.Top; batchElement.BringToFront(); _BatchElementsMulti.Add(batchElement); } } }
/*****************************************\ * Save new batch * * -> Check validity * * -> Suppress old batch if exists * * -> Add batch to the list of batchs * * -> Remove old batch row if exist * * -> Add batch to the datagrid * * -> Clear Batch elements UCs * \*****************************************/ private void SaveButtonSpec_Click(object sender, EventArgs e) { // Check if each element is correctly, save if ok if (CheckBatch()) { // Suppress old batch if exists foreach (Batch element in _BatchsList) { if (element.Get_Name().Equals(BatchNameTextBox.Text)) { _BatchsList.Remove(element); break; } } // Add batch to the list of batchs Batch batch = new Batch(BatchNameTextBox.Text, "Single"); foreach (BatchElement element in _BatchElements) { batch.AddBatchElement(element.Get_TargetPath(), element.Get_ConfigName(), element.Get_ConfigPath(),element.Get_FtpRegion()); } _BatchsList.Add(batch); KryptonMessageBox.Show("Saved !", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); // Remove old batch row if exist foreach (DataGridViewRow element in BatchsDataGridView.Rows) { if (element.Cells[0].Value.Equals(BatchNameTextBox.Text)) { BatchsDataGridView.Rows.Remove(element); break; } } // Add batch to the datagrid BatchsDataGridView.AllowUserToAddRows = true; DataGridViewRow row = (DataGridViewRow)BatchsDataGridView.Rows[0].Clone(); row.Cells[0].Value = batch.Get_Name(); BatchsDataGridView.Rows.Add(row); BatchsDataGridView.AllowUserToAddRows = false; // Clear Batch creation elements SplitContainer.Panel2Collapsed = true; SplitContainer.Panel2.Hide(); Form form = (Form)this.Parent; form.Size = new System.Drawing.Size(form.Width - 300, form.Height); BatchNameTextBox.Text = ""; BatchNameTextBoxMulti.Text = ""; TutoLabel.Visible = true; foreach (BatchElement element in _BatchElements) element.Dispose(); _BatchElements.Clear(); foreach (BatchElementMulti element2 in _BatchElementsMulti) element2.Dispose(); _BatchElementsMulti.Clear(); EditToolStripButton.Enabled = true; AddToolStripButton.Enabled = true; RemoveToolStripButton.Enabled = true; } }
/****************************************************** SINGLE MODE *******************************************************/ /***********************************\ * Instanciate graphical elements * \***********************************/ private void InstanciateBatchGraphical(Batch batch) { // Set navigator page Navigator.SelectedIndex = 0; // Open creation section if (SplitContainer.Panel2Collapsed) { Form form = (Form)this.Parent; form.Size = new System.Drawing.Size(form.Width + 300, form.Height); SplitContainer.Panel2Collapsed = false; SplitContainer.Panel2.Show(); } else { BatchNameTextBox.Text = ""; BatchNameTextBoxMulti.Text = ""; foreach (BatchElement element in _BatchElements) element.Dispose(); _BatchElements.Clear(); foreach (BatchElementMulti element2 in _BatchElementsMulti) element2.Dispose(); _BatchElementsMulti.Clear(); } // Add graphical elements if (batch.Get_Type().Equals("Single")) { BatchNameTextBox.Text = batch.Get_Name(); foreach (KeyValuePair<string, Tuple<string, string, string>> element in batch.Get_BatchElements()) { BatchElement batchElement = new BatchElement(_RegionsList); batchElement.Config.Text = element.Value.Item1.Replace(".xml", ""); batchElement.Set_TargetPathTooltip(element.Key); batchElement.Set_TargetPath(element.Key); batchElement.Set_ConfigPath(element.Value.Item2); batchElement.Set_ConfigName(element.Value.Item1.Replace(".xml", "")); batchElement.Set_FtpRegion(element.Value.Item3); batchElement.FTPComboBox.SelectedItem = element.Value.Item3; batchElement.SuppressButton.Click += SuppressButton_Click; // Add new element to the UC BatchElementsGroupBox.Panel.Controls.Add(batchElement); batchElement.Dock = DockStyle.Top; batchElement.BringToFront(); _BatchElements.Add(batchElement); } } }
private KryptonForm _WaitScreenForm; // Form hosting the WaitingScreen UC. #endregion Fields #region Constructors public Main() { InitializeComponent(); _FileBrowser = new FileBrowser(InitializePath()); if (Directory.Exists(Properties.Settings.Default.local_path)) _LocalFileBrowser = new FileBrowser(Properties.Settings.Default.local_path); else _LocalFileBrowser = new FileBrowser(@"D:\\"); _ClearProgressBarDel = new ProcessOnMainThread6(ClearAllProgressBars); _Navigator = new Navigator(ProcessHelperButton, _ClearProgressBarDel); _SpecificCountries = new SpecificCountries(); _SpecificTools = new SpecificTools(); _Session = new Authentication("user"); _Session.CheckSavedPUC(System.Environment.MachineName); _Administration = new Administration(); _Settings = new Settings(); _Chronicles = new History(); _ConfigSummary = new ConfigSummary(); _FtpManager = new FTPManager.FTPManager(); _Batch = new BatchUC(_FtpManager.Get_RegionsList()); LoadBatchs(); // Load batch objects from saved instance. _Batch.LoadBatchs(); // Load them graphically (rows in DGV). _WaitingScreen = new WaitingScreen(); InitializeInterface(); _ConfigsList = new List<Config>(); _InputFiles = new List<String>(); _PoolThreads = new List<Thread>(); _LaunchersList = new List<Launcher>(); _ProgressBarsList = new List<ProgressBar>(); _LogsList = new List<Log>(); _IsCopy = false; _SourcePath = null; _TargetPath = null; _PreviousNodeName = null; _LogsPath = null; _UpdateProgressBarDel = new processOnMainThread(UpdateProgressBar); _UpdateRichTextBoxDel = new processOnMainThread2(UpdateRichTextBox); _AddLogsGridViewDel = new processOnMainThread3(AddLogsGridView); _DisplayConfigProcessTimeDel = new ProcessOnMainThread4(DisplayConfigProcessTime); _AbortThreadDel = new ProcessOnMainThread5(AbortThread); _FTPWorker = new BackgroundWorker(); _FTPWorker.WorkerReportsProgress = true; _FTPWorker.WorkerSupportsCancellation = true; _FTPWorker.DoWork += _FTPWorker_DoWork; _FTPWorker.RunWorkerCompleted += _FTPWorker_RunWorkerCompleted; _FTPWorker.ProgressChanged += _FTPWorker_ProgressChanged; _FtpDLCounter = 1; _BatchTargetPathsTmp = new List<string>(); _RegionsToDownload = new List<FTPManager.Region>(); _LaunchedBatchType = String.Empty; _LaunchedBatch = new Batch(); }
/****************************************************\ * Event of double clicking batch listbox item : * * -> LAUNCH selected batch * \****************************************************/ private void BatchListBox_MouseDoubleClick(object sender, MouseEventArgs e) { _BatchTargetPathsTmp.Clear(); _RegionsToDownload.Clear(); /* Display Summary page */ _Navigator.NavigatorControl.SelectedPage = _Navigator.NavigatorControl.Pages[0]; /* Retrieve batch to launch */ foreach (Batch element in _Batch.Get_BatchsList()) { if (element.Get_Name().Equals(BatchListBox.SelectedItem.ToString())) { _LaunchedBatch = element; if (element.Get_Type().Equals("Single")) _LaunchedBatchType = "Single"; else if (element.Get_Type().Equals("Multi")) _LaunchedBatchType = "Multi"; Boolean hasFtpDownload = false; if(_LaunchedBatchType.Equals("Single")) foreach (KeyValuePair<string, Tuple<string, string, string>> element2 in element.Get_BatchElements()) { /* Check if batch element has FTP Download */ if (!String.IsNullOrEmpty(element2.Value.Item3) && !element2.Value.Item3.Equals("-")) hasFtpDownload = true; } else if (_LaunchedBatchType.Equals("Multi")) foreach (KeyValuePair<Tuple<string, string>, List<Tuple<string, string>>> element2 in element.Get_BatchElementsMulti()) { /* Check if batch element has FTP Download */ if (!String.IsNullOrEmpty(element2.Key.Item2) && !element2.Key.Item2.Equals("-")) hasFtpDownload = true; } /* If no FTP download required, start directly the reformating */ if (!hasFtpDownload) { if(_LaunchedBatchType.Equals("Single")) LaunchBatchSingle(element); else LaunchBatchMulti(element); } /* Else download files (first get list of regions to connect for downloading files) */ else { _FtpDLCounter = 1; if (_LaunchedBatchType.Equals("Single")) { foreach (KeyValuePair<string, Tuple<string, string, string>> element3 in element.Get_BatchElements()) foreach (FTPManager.Region region in _FtpManager.Get_RegionsList()) if (element3.Value.Item3.Equals(region.Get_RegionName())) { _RegionsToDownload.Add(region); _BatchTargetPathsTmp.Add(element3.Key); } } else if (_LaunchedBatchType.Equals("Multi")) { foreach (KeyValuePair<Tuple<string, string>, List<Tuple<string, string>>> element4 in element.Get_BatchElementsMulti()) foreach (FTPManager.Region region2 in _FtpManager.Get_RegionsList()) if (element4.Key.Item2.Equals(region2.Get_RegionName())) { _RegionsToDownload.Add(region2); _BatchTargetPathsTmp.Add(element4.Key.Item1); } } /* Don't check region if target directory has not been set*/ for (int i = 0; i < _RegionsToDownload.Count; i++ ) { if (!System.IO.Directory.Exists(_RegionsToDownload[i].Get_TargetDirectory())) { _RegionsToDownload.Remove(_RegionsToDownload[i]); if(i!=0)i--; var result = KryptonMessageBox.Show(_RegionsToDownload[i].Get_RegionName() + " will not been included because target directory is wrong or not defined.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } List<object> arguments = new List<object>(); arguments.Add("DlLastUp"); arguments.Add(_FtpDLCounter - 1); _FTPWorker.RunWorkerAsync(arguments); _WaitScreenForm.Show(); _FtpManagerForm.Show(); _FtpManager.Get_LogCat().AppendText("Connecting to " + _RegionsToDownload[0].Get_RegionName() + " : " + _RegionsToDownload[0].Get_FtpHost() + "... "); /* Clear interface */ _FtpManager.Get_ProgressBar().Value = 0; _FtpManager.Get_ProgressLabel().Text = "-"; _FtpManager.Get_DirFileCounterLabel().Text = ""; _FtpManager.Get_FTPBrowserHeaderGroup().ValuesPrimary.Heading = "FTP Browser :"; } /* Launch batch (MULTI MODE) */ //else if (element.Get_Type().Equals("Multi")) // LaunchBatchMulti(element); break; } } }
private void LaunchBatchSingle(Batch batch) { foreach (KeyValuePair<string, Tuple<string, string, string>> element in batch.Get_BatchElements()) { /* Define paths (input, logs) */ DirectoryInfo targetPath = new DirectoryInfo(element.Key); FileInfo[] inputFiles = targetPath.GetFiles(); _InputFiles.Clear(); foreach (FileInfo file in inputFiles) { _InputFiles.Add(file.FullName); _LogsPath = file.Directory.FullName; } /* Create a new config */ Config config = new Config(element.Value.Item1, element.Value.Item2); /* Create launcher and associated UC. */ _LaunchersList.Add(new Launcher(config, PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked, HCButton.Checked, new List<String>(_InputFiles), _LogsPath, _UpdateProgressBarDel, _UpdateRichTextBoxDel, _AddLogsGridViewDel, _DisplayConfigProcessTimeDel)); _ProgressBarsList.Add(new ProgressBar(config.Get_Name(), _ProgressBarsList.Count, _AbortThreadDel)); _Navigator.ProgressGroupBox.Panel.Controls.Add(_ProgressBarsList[_ProgressBarsList.Count - 1]); _LogsList.Add(new Log(config.Get_Name(), config.Get_TargetsNumber(), PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked)); _Navigator.LogsNavigator.Pages.Insert(0, _LogsList[_LogsList.Count - 1].Get_NavigatorTab()); _Navigator.LogsNavigator.SelectedIndex = 0; _LogsList[_LogsList.Count - 1].Get_NavigatorTab().ButtonSpecs[0].Click += new EventHandler(_Navigator.CloseLogsNavigatorTab); _PoolThreads.Add(new Thread(() => _LaunchersList[_LaunchersList.Count - 1].Run(_LaunchersList.Count - 1))); _PoolThreads[_PoolThreads.Count - 1].IsBackground = true; _PoolThreads[_PoolThreads.Count - 1].Start(); } }
private void LaunchBatchMulti(Batch batch) { foreach (KeyValuePair<Tuple<string,string>, List<Tuple<string, string>>> element in batch.Get_BatchElementsMulti()) { int configCounter = 1; // Define paths (input, logs) DirectoryInfo targetPath = new DirectoryInfo(element.Key.Item1); FileInfo[] inputFiles = targetPath.GetFiles(); _InputFiles.Clear(); foreach (FileInfo file in inputFiles) _InputFiles.Add(file.FullName); // Create Config/Instanciate launcher for each config of each batch element foreach (Tuple<string, string> config in element.Value) { // Copy all inputs in a separated directory if (!Directory.Exists(targetPath + "\\" + configCounter.ToString())) Directory.CreateDirectory(targetPath + "\\" + configCounter.ToString()); foreach (String input in _InputFiles) File.Copy(input, targetPath + "\\" + configCounter.ToString() + "\\" + Path.GetFileName(input), true); // Redefine paths DirectoryInfo specificTargetPath = new DirectoryInfo(targetPath + "\\" + configCounter.ToString()); FileInfo[] specificInputFiles = specificTargetPath.GetFiles(); List<string> specificInputs = new List<string>(); string specificLogPath = specificTargetPath.FullName; foreach (FileInfo file in specificInputFiles) specificInputs.Add(file.FullName); // Create a new config Config specificConfig = new Config(config.Item1, config.Item2); // Create launcher and associated UC. _LaunchersList.Add(new Launcher(specificConfig, PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked, HCButton.Checked, new List<String>(specificInputs), specificLogPath, _UpdateProgressBarDel, _UpdateRichTextBoxDel, _AddLogsGridViewDel, _DisplayConfigProcessTimeDel)); _ProgressBarsList.Add(new ProgressBar(specificConfig.Get_Name(), _ProgressBarsList.Count, _AbortThreadDel)); _Navigator.ProgressGroupBox.Panel.Controls.Add(_ProgressBarsList[_ProgressBarsList.Count - 1]); _LogsList.Add(new Log(specificConfig.Get_Name(), specificConfig.Get_TargetsNumber(), PreProcessButton.Checked, ProcessButton.Checked, ControlsButton.Checked)); _Navigator.LogsNavigator.Pages.Insert(0, _LogsList[_LogsList.Count - 1].Get_NavigatorTab()); _Navigator.LogsNavigator.SelectedIndex = 0; _LogsList[_LogsList.Count - 1].Get_NavigatorTab().ButtonSpecs[0].Click += new EventHandler(_Navigator.CloseLogsNavigatorTab); _PoolThreads.Add(new Thread(() => _LaunchersList[_LaunchersList.Count - 1].Run(_LaunchersList.Count - 1))); _PoolThreads[_PoolThreads.Count - 1].IsBackground = true; _PoolThreads[_PoolThreads.Count - 1].Start(); configCounter++; } } }