Пример #1
0
 private void WriteStepEventFile(string eventsFileDirectory, int stepNumber, checkboxItems checkboxItems)
 {
     StreamWriter writer = new StreamWriter(eventsFileDirectory + @"\step" + stepNumber + "_events.xml");
     try {
         writer.Write(checkboxItems.stepEvents);
     } finally {
         if (writer != null) {
             writer.Flush();
             writer.Close();
             writer.Dispose();
         }
     }
 }
Пример #2
0
        private XmlNode GetRespectiveChildNode(checkboxItems selectedItem, XmlDocument xDoc)
        {
            XmlNode node = null;

            for (int i = 0; i < xDoc.DocumentElement.ChildNodes.Count; i++) {
            //    if (xDoc.DocumentElement.ChildNodes[i]) {

            //    }
            }

            return node;
        }
Пример #3
0
        private void StartSplittingFile()
        {
            if (!Directory.Exists(txtOutputDir.Text)) {
                Directory.CreateDirectory(txtOutputDir.Text);
            }

            string sessionKey = string.Empty;
            sessionKey = txtSessionKey.Text.Trim();
            string fileRead = string.Empty;
            StreamReader reader = new StreamReader(txtDirectory.Text);
            string eventsFile = "<Steps label=\"Automatically Generated\">";
            try {
                fileRead = reader.ReadToEnd();
                MatchCollection collection = Regex.Matches(fileRead, "<Comment.*>(.*)</Comment>");
                List<string> matches = new List<string>();
                for (int i = 0; i < collection.Count; i++) {
                    matches.Add(collection[i].Groups[1].ToString());
                    //     txtOutput.Text = txtOutput.Text + "\r\n" + collection[i].Groups[1].ToString();
                }

                string newFileRead = Regex.Replace(fileRead, "<Comment.*</Comment>", "</Events></MXClientScript><!-- --><MXClientScript><Events>");
                string[] test = new string[] { "<!-- -->" };
                string[] splitArray = newFileRead.Split(test, StringSplitOptions.RemoveEmptyEntries);

                for (int j = 0; j < splitArray.Length; j++) {
                    if (j < collection.Count) {
                        StreamWriter writer = new StreamWriter(txtOutputDir.Text + @"\step" + (j + 1) + "_events.xml");
                        StreamWriter guiWriter = new StreamWriter(txtOutputDir.Text + @"\step" + (j + 1) + "_gui.xml");
                        StreamWriter customsWriter = new StreamWriter(txtOutputDir.Text + @"\step" + (j + 1) + "_customs.xml");
                        try {
                            guiWriter.Write(" ");
                            customsWriter.Write(@"<Customs></Customs>");
                            writer.Write(splitArray[j]);
                            if (string.IsNullOrEmpty(sessionKey)) {

                                eventsFile = eventsFile + "\r\n <Step id=\"" + (j + 1) + "\" label=\"" + collection[j].Groups[1].ToString() + "\" events=\"step" + (j + 1) + "_events.xml\" gui=\"step" + (j + 1) + "_gui.xml\" customs=\"step" + (j + 1) + "_customs.xml\"></Step>";

                            } else {
                                eventsFile = eventsFile + "\r\n <Step id=\"" + (j + 1) + "\" sessionKey=\"" + sessionKey + "\" label=\"" + collection[j].Groups[1].ToString() + "\" events=\"step" + (j + 1) + "_events.xml\" gui=\"step" + (j + 1) + "_gui.xml\" customs=\"step" + (j + 1) + "_customs.xml\"></Step>";

                            }
                            checkboxItems item = new checkboxItems();
                            item.filepath = txtOutputDir.Text + @"\step" + (j + 1) + "_events.xml";
                            item.stepName = "step" + (j + 1) + "_events.xml";
                            item.stepTitle = collection[j].Groups[1].ToString();
                            item.stepEvents = splitArray[j];
                            chkLstAllStepEvents.Items.Add(item);
                        } finally {
                            if (writer != null) {
                                writer.Close();
                            }
                            if (guiWriter != null) {
                                guiWriter.Close();
                            }
                            if (customsWriter != null) {
                                customsWriter.Close();
                            }
                        }
                    } else {
                        StreamWriter writer = new StreamWriter(txtOutputDir.Text + @"\step" + (j + 1) + "_events.xml");
                        try {

                            writer.Write(splitArray[j]);

                            if (string.IsNullOrEmpty(sessionKey)) {

                                eventsFile = eventsFile + "\r\n <Step id=\"" + (j + 1) + "\" label=\"Exit\" events=\"step" + (j + 1) + "_events.xml\"></Step>";

                            } else {
                                eventsFile = eventsFile + "\r\n <Step id=\"" + (j + 1) + "\" sessionKey=\"" + sessionKey + "\" label=\"Exit\" events=\"step" + (j + 1) + "_events.xml\"></Step>";

                            }
                            checkboxItems item = new checkboxItems();
                            item.filepath = txtOutputDir.Text + @"\step" + (j + 1) + "_events.xml";
                            item.stepName = "step" + (j + 1) + "_events.xml";
                            item.stepTitle = "Exit";
                            item.stepEvents = splitArray[j];
                            chkLstAllStepEvents.Items.Add(item);
                        } finally {
                            if (writer != null) {
                                writer.Close();
                            }
                        }

                    }

                }
            } finally {
                if (reader != null) {
                    reader.Close();
                }
            }

            StreamWriter eventsfilesWriter = new StreamWriter(txtOutputDir.Text + @"\eventsfiles.xml");
            try {
                eventsFile = eventsFile + "</Steps>";
                eventsfilesWriter.Write(eventsFile);
                oldEventsFile = eventsFile;
            } finally {
                if (eventsfilesWriter != null) {
                    eventsfilesWriter.Close();
                }
            }
        }
Пример #4
0
 private void CleanOutputDir(checkboxItems checkboxItems)
 {
     File.Delete(checkboxItems.filepath);
     string parentDirectory = Directory.GetParent(checkboxItems.filepath).ToString();
     if (File.Exists(parentDirectory + @"\" + Path.GetFileName(checkboxItems.filepath).Replace("events", "customs"))) {
         File.Delete(parentDirectory + @"\" + Path.GetFileName(checkboxItems.filepath).Replace("events", "customs"));
     }
     if (File.Exists(parentDirectory + @"\" + Path.GetFileName(checkboxItems.filepath).Replace("events", "gui"))) {
         File.Delete(parentDirectory + @"\" + Path.GetFileName(checkboxItems.filepath).Replace("events", "gui"));
     }
 }