private void btnGroup_Click(object sender, EventArgs e) { try { chkFsEvents.Enabled = false; if (chkLstAllStepEvents.Items.Count == 0) { CommonUtils.ShowError("There is no steps to group!", null); return; } List<checkboxItems> selectedItems = new List<checkboxItems>(); System.Windows.Forms.CheckedListBox.CheckedItemCollection checkedCollection = chkLstAllStepEvents.CheckedItems; for (int i = 0; i < checkedCollection.Count; i++) { selectedItems.Add(checkedCollection[i] as checkboxItems); } SessionKeyAndTitleForm form = new SessionKeyAndTitleForm(txtOutputDir.Text); DialogResult result = form.ShowDialog(); SetDefaultFormValues(form); if (result == DialogResult.OK) { File.Delete(Directory.GetParent(selectedItems[0].filepath) + @"\eventsfiles.xml"); for (int i = 0; i < selectedItems.Count; i++) { CleanOutputDir(selectedItems[i]); chkLstAllStepEvents.Items.Remove(selectedItems[i]); } int startIndex = Convert.ToInt32(((NumericUpDown)form.Controls["nudStartIndex"]).Value); string outputFolderName = form.Controls["txtTitle"].Text + "-" + form.eventsGroupNameAndID.OperationGeneratedID; GenerateSplitFile(selectedItems, form.sessionKey, outputFolderName, startIndex); CreateBuildXmlFile(form.Controls["txtTitle"].Text, outputFolderName ); } } catch (Exception ex) { CommonUtils.ShowError(ex.Message, ex); } }
// int groupNumber = 0; private void btnGroup_Click(object sender, EventArgs e) { try { chkFsEvents.Enabled = false; if (chkLstAllStepEvents.Items.Count == 0) { MessageBox.Show("There is no steps to group!"); return; } List<checkboxItems> selectedItems = new List<checkboxItems>(); System.Windows.Forms.CheckedListBox.CheckedItemCollection checkedCollection = chkLstAllStepEvents.CheckedItems; for (int i = 0; i < checkedCollection.Count; i++) { selectedItems.Add(checkedCollection[i] as checkboxItems); } SessionKeyAndTitleForm form = new SessionKeyAndTitleForm(txtOutputDir.Text); DialogResult result = form.ShowDialog(); SetDefaultFormValues(form); if (result == DialogResult.OK) { File.Delete(Directory.GetParent(selectedItems[0].filepath) + @"\eventsfiles.xml"); for (int i = 0; i < selectedItems.Count; i++) { CleanOutputDir(selectedItems[i]); chkLstAllStepEvents.Items.Remove(selectedItems[i]); } GenerateSplitFile(selectedItems, form.Controls["txtSessionKey"].Text, form.Controls["txtTitle"].Text); // if(chkFsEvents.Checked){ // fsEventsFile = PrepareFsEventsFile(selectedItems,oldEventsFile); // oldEventsFile = fsEventsFile; // } CreateBuildXmlFile(form.Controls["txtTitle"].Text, form.Controls["txtTitle"].Text + @"\eventsfiles.xml"); //groupNumber++; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private static void SetDefaultFormValues(SessionKeyAndTitleForm form) { Random random = new Random(DateTime.Now.Millisecond); form.Controls["txtSessionKey"].Text = random.Next(8999).ToString(); }
private void groupToolStripMenuItem_Click(object sender, EventArgs e) { Control control = GetSourceControl((sender as ToolStripMenuItem).GetCurrentParent()) as Control; MWTreeView treeView = control as MWTreeView; if (treeView != null) { if (treeView.SelNodes.Count > 0) { SessionKeyAndTitleForm form = new SessionKeyAndTitleForm(txtOutputDir.Text); DialogResult result = form.ShowDialog(); SetDefaultFormValues(form); if (result == DialogResult.OK) { int startIndex = Convert.ToInt32(((NumericUpDown)form.Controls["nudStartIndex"]).Value); string outputFolderName = form.Controls["txtFolderName"].Text + "-" + form.eventsGroupNameAndID.OperationGeneratedID; string testTitle = form.Controls["txtTestTitle"].Text; object[] selectedKeys = new object[treeView.SelNodes.Count]; treeView.SelNodes.Keys.CopyTo(selectedKeys, 0); List<BulkMacroTreeNode> selectedNodes = new List<BulkMacroTreeNode>(); bool emptyParentInSelection = false; for (int i = 0; i < selectedKeys.Length; i++) { BulkMacroTreeNode node = (treeView.SelNodes[selectedKeys[i]] as Automation.Common.MWTreeNodeWrapper).Node as BulkMacroTreeNode; if (!node.Text.Contains("|")) { emptyParentInSelection = true; } selectedNodes.Add(node); } if (!emptyParentInSelection) { tvResults.ClearSelNodes(); selectedNodes.Sort(BulkMacroTreeNode.stepIndexComparison); List<BulkMacroTreeNode> movedNodes = new List<BulkMacroTreeNode>(); for (int i = 0; i < selectedNodes.Count; i++) { BulkMacroTreeNode bulkMacroTreeNode = selectedNodes[i].Clone() as BulkMacroTreeNode; bulkMacroTreeNode.endStepId = selectedNodes[i].endStepId; bulkMacroTreeNode.filepathEvents = selectedNodes[i].filepathEvents; bulkMacroTreeNode.startStepId = selectedNodes[i].startStepId; bulkMacroTreeNode.stepEvents = selectedNodes[i].stepEvents; bulkMacroTreeNode.filepathCustoms = selectedNodes[i].filepathCustoms; bulkMacroTreeNode.filepathGui = selectedNodes[i].filepathGui; bulkMacroTreeNode.filepathGuiGim = selectedNodes[i].filepathGuiGim; CleanOutputDir(bulkMacroTreeNode); //outputFolderName bulkMacroTreeNode.stepName = Regex.Replace(selectedNodes[i].stepName, "\\d+", ((i) + startIndex).ToString()); bulkMacroTreeNode.stepTitle = selectedNodes[i].stepTitle; bulkMacroTreeNode.Text = bulkMacroTreeNode.stepName + " | " + bulkMacroTreeNode.stepTitle; bulkMacroTreeNode.filepathEvents = Directory.GetParent(bulkMacroTreeNode.filepathEvents) + @"\" + outputFolderName + @"\" + bulkMacroTreeNode.stepName; tvResults.DeselectNode(bulkMacroTreeNode, true); selectedNodes[0].Nodes.Add(bulkMacroTreeNode); //outputFolderName selectedNodes[0].isParentNode = true; selectedNodes[0].Tag = outputFolderName; movedNodes.Add(bulkMacroTreeNode); if (i > 0) { selectedNodes[i].Remove(); } } selectedNodes[0].Text = testTitle; selectedNodes[0] = new BulkMacroTreeNode(); GenerateSplitFile(movedNodes, form.sessionKey, outputFolderName, startIndex); CreateBuildXmlFile(testTitle, outputFolderName); File.Delete(Directory.GetParent(txtOutputDir.Text) + @"\eventsfiles.xml"); } } } tvResults.ExpandAll(); } }