Esempio n. 1
0
        private void BtCheckRelease_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();

            if (Directory.Exists(TbFPDir.Text))
            {
                fbd.SelectedPath = new DirectoryInfo(TbFPDir.Text).Parent.FullName;
            }

            if (fbd.ShowDialog() == DialogResult.OK)
            {
                DirectoryInfo releaseDir = new DirectoryInfo(fbd.SelectedPath);

                ScenarioUtils.CheckFilesAndPatchScenario(releaseDir, releaseDir.EnumerateDirectories("*", SearchOption.TopDirectoryOnly).ToList(), out List <string> scenarioNotFound, out List <string> filesNotFound, out List <string> linesNotFound, out List <string> objectDuplications);

                if (scenarioNotFound.Count > 0 || filesNotFound.Count > 0 || linesNotFound.Count > 0)
                {
                    CheckForm cf = new CheckForm(
                        string.Join(Environment.NewLine, scenarioNotFound),
                        string.Join(Environment.NewLine, filesNotFound),
                        string.Join(Environment.NewLine, linesNotFound),
                        "");

                    DialogResult dr = cf.ShowDialog();
                }
            }
        }
Esempio n. 2
0
        public static bool CreateFPScenarioByPatchesScenario(DirectoryInfo fixpackDirectory, List <DirectoryInfo> selectedPatches, List <DirectoryInfo> beforeInstructionPatches)
        {
            CheckFilesAndPatchScenario(fixpackDirectory, selectedPatches, out List <string> scenarioNotFound, out List <string> filesNotFound, out List <string> linesNotFound, out List <string> objectDuplications);

            CheckForm cf = null;

            if (scenarioNotFound.Count > 0 || filesNotFound.Count > 0 || linesNotFound.Count > 0 || objectDuplications.Count > 0)
            {
                cf = new CheckForm(
                    string.Join(Environment.NewLine, scenarioNotFound),
                    string.Join(Environment.NewLine, filesNotFound),
                    string.Join(Environment.NewLine, linesNotFound),
                    string.Join(Environment.NewLine, objectDuplications));

                DialogResult dr = cf.ShowDialog();

                if (dr == DialogResult.Abort || dr == DialogResult.Cancel)
                {
                    return(false);
                }
            }

            List <string> newScenarioLines = new List <string>();

            DirectoryInfo        fixpackDir       = new DirectoryInfo(Properties.Settings.Default.fixpackPath);
            List <DirectoryInfo> patchDirectories = fixpackDir.GetDirectories("*", SearchOption.TopDirectoryOnly).ToList();

            patchDirectories.Sort((x, y) => x.Name.CompareTo(y.Name));

            foreach (DirectoryInfo patchDirectory in patchDirectories)
            {
                if (selectedPatches.Where(x => x.FullName.Equals(patchDirectory.FullName, StringComparison.InvariantCultureIgnoreCase)).Count() > 0)
                {
                    var fileScs = patchDirectory.GetFiles("file_sc.txt", SearchOption.TopDirectoryOnly);
                    if (fileScs.Length != 0)
                    {
                        using (var reader = fileScs[0].OpenText())
                        {
                            string        currScenario      = reader.ReadToEnd();
                            string[]      currScenarioLines = currScenario.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                            List <string> listScenarioLines = currScenarioLines.ToList();
                            DefaultScenarioOrderValidation(listScenarioLines);
                            List <string> newPatchScenarioLines = new List <string>();

                            newPatchScenarioLines = CreateNewScenarioLines(fixpackDirectory, patchDirectory, listScenarioLines);

                            if (beforeInstructionPatches.Where(x => x.FullName.Equals(patchDirectory.FullName, StringComparison.InvariantCultureIgnoreCase)).Count() > 0)
                            {
                                newPatchScenarioLines.Insert(0, $"WAIT||Выполнить Датафикс №{patchDirectory.Name}");
                            }

                            if (cf != null && cf.AddRows)
                            {
                                for (int j = 0; j < linesNotFound.Count; ++j)
                                {
                                    if (FolderFromNewScenarioLine.Match(linesNotFound[j]).Groups[1].Value.Equals(patchDirectory.Name, StringComparison.InvariantCultureIgnoreCase))
                                    {
                                        bool lineAdded = false;
                                        for (int i = 0; i < newPatchScenarioLines.Count; ++i)
                                        {
                                            int p1 = Priority(linesNotFound[j]);
                                            int p2 = Priority(newPatchScenarioLines[i]);
                                            //сначала по приоритету, при равенстве - по алфавиту
                                            if (p1 < p2 || p1 == p2 && linesNotFound[j].CompareTo(newPatchScenarioLines[i]) < 0)
                                            {
                                                newPatchScenarioLines.Insert(i, linesNotFound[j]);
                                                lineAdded = true;
                                                break;
                                            }
                                        }
                                        if (!lineAdded)
                                        {
                                            newPatchScenarioLines.Add(linesNotFound[j]);
                                        }
                                    }
                                }
                            }
                            newScenarioLines.AddRange(newPatchScenarioLines);
                        }
                    }
                }
            }

            if (cf != null && cf.DeleteRows)
            {
                newScenarioLines.RemoveAll(x => filesNotFound.Contains(x, StringComparer.InvariantCultureIgnoreCase));
            }

            SaveFileSc(fixpackDirectory, newScenarioLines);
            return(true);
        }