Пример #1
0
        private void Button_Remove_Click(object sender, EventArgs e)
        {
            if (treeView.SelectedNode != null)
            {
                treeView.SelectedNode.Remove();
                if (treeView.SelectedNode.Tag is SeSchema)
                {
                    UpdateComboBox();
                }
                else if (treeView.SelectedNode.Tag is SeSchemaItem)
                {
                    SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag;

                    if (treeView.SelectedNode.Parent.Tag is SeSchemaItem)
                    {
                        SeSchemaItem ssiParent = (SeSchemaItem)treeView.SelectedNode.Parent.Tag;
                        ssiParent.SchemaItemsChildren.Remove(ssi);
                    }
                    else if (treeView.SelectedNode.Parent.Tag is SeSchema)
                    {
                        SeSchema ssiParent = (SeSchema)treeView.SelectedNode.Parent.Tag;
                        ssiParent.SchemaItems.Remove(ssi);
                    }
                }
            }
            else
            {
                MessageBox.Show("Для удаления элемента нажмите на ветку дерева");
            }
        }
Пример #2
0
        private void открытьСхемыФТСToolStripMenuItem_Click(object sender, EventArgs e)
        {
            treeView.SelectedNode = null;
            DirectoryInfo   diXsd = new DirectoryInfo(Path.Combine(Application.StartupPath, @"..\..\Resources\xsd\фтс2\"));
            XmlSchemaSet    xss   = ReadXSD(diXsd);
            SeSchema        seSchema;
            List <SeSchema> seSchemaList = null;

            this.Cursor = Cursors.WaitCursor;

            treeView.BeginUpdate();

            foreach (XmlSchema schema in xss.Schemas())
            {
                seSchema     = new SeSchema(schema);
                seSchemaList = seSchemaList ?? new List <SeSchema>();
                seSchemaList.Add(seSchema);
                seSchema.ClassToTreeView(treeView.Nodes);
            }
            treeView.EndUpdate();
            this.Cursor = Cursors.Default;
            ComboBoxBind(seSchemaList);
            BtnToTV.Enabled        = true;
            button_Refresh.Enabled = true;
            Button_Remove.Enabled  = true;
        }
Пример #3
0
 private void Button_Add_Click(object sender, EventArgs e)
 {
     if (treeView.SelectedNode != null)
     {
         SeSchemaItem newssi      = new SeSchemaItem();
         TreeNode     newTreeNode = new TreeNode();
         newTreeNode.Text       = newssi.ToString();
         newTreeNode.Tag        = newssi;
         newTreeNode.ImageIndex = 1;
         treeView.SelectedNode.Nodes.Add(newTreeNode);
         if (treeView.SelectedNode.Tag is SeSchema)
         {
             SeSchema seSchema = (SeSchema)treeView.SelectedNode.Tag;
             newssi.Parent = seSchema;
             seSchema.SchemaItems.Add(newssi);
         }
         else if (treeView.SelectedNode.Tag is SeSchemaItem)
         {
             SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag;
             if (ssi.SchemaItemsChildren == null)
             {
                 ssi.SchemaItemsChildren = new List <SeSchemaItem>();
             }
             newssi.Parent = ssi;
             ssi.SchemaItemsChildren.Add(newssi);
         }
     }
     else
     {
         MessageBox.Show("Для добавления нового элемента нажмите на ветку дерева");
     }
     //UpdateTreeView(treeView1.Nodes);
 }
Пример #4
0
        private void схемуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SeSchema newSchema = new SeSchema();

            newSchema.ClassToTreeView(treeView.Nodes);
            UpdateComboBox();
        }
Пример #5
0
            StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
            {
                List <string> str = new List <string>();

                str.Add("");
                foreach (CommonType simpletype in Enum.GetValues(typeof(CommonType)))
                {
                    str.Add(simpletype.ToString().ToLower());
                }
                SeSchemaItem ssi = (SeSchemaItem)context.Instance;

                while (ssi.Parent is SeSchemaItem)
                {
                    ssi = (SeSchemaItem)ssi.Parent;
                }

                SeSchema ss = (SeSchema)ssi.Parent;

                foreach (SeSchemaItem ssiTable in ss.SchemaItems)
                {
                    if (ssiTable.Type == "")
                    {
                        str.Add(ssiTable.Name);
                    }
                }

                return(new StandardValuesCollection(str));
            }
Пример #6
0
        private void элементToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (treeView.SelectedNode != null)
            {
                SeSchemaItem newssi      = new SeSchemaItem();
                TreeNode     newTreeNode = new TreeNode();
                newTreeNode.Text = newssi.ToString();
                newTreeNode.Tag  = newssi;

                treeView.SelectedNode.Nodes.Add(newTreeNode);
                if (treeView.SelectedNode.Tag is SeSchema)
                {
                    SeSchema seSchema = (SeSchema)treeView.SelectedNode.Tag;
                    newssi.Parent = seSchema;
                    seSchema.SchemaItems.Add(newssi);
                }
                else if (treeView.SelectedNode.Tag is SeSchemaItem)
                {
                    SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag;
                    if (ssi.SchemaItemsChildren == null)
                    {
                        ssi.SchemaItemsChildren = new List <SeSchemaItem>();
                    }
                    newssi.Parent = ssi;
                    ssi.SchemaItemsChildren.Add(newssi);
                }
            }
            else
            {
                MessageBox.Show("Для добавления нового элемента или схемы нажмите на ветку TreeView");//?
            }
        }
Пример #7
0
        /// <summary>
        /// Изменение элементов при изменении имени ComplexType
        /// </summary>
        /// <param name="oldValue">Старое значение поля Name</param>
        /// <param name="newValue">Новое значение поля Name</param>
        public void ChangeNewComplexType(object oldValue, object newValue)
        {
            SeSchema ss = (SeSchema)Parent;

            foreach (SeSchemaItem ssiElement in ss.SchemaItems)
            {
                if (ssiElement.Type == oldValue.ToString())
                {
                    ssiElement.Type = newValue.ToString();
                }
                if (ssiElement.SchemaItemsChildren != null)
                {
                    foreach (SeSchemaItem ssiElementEach in ssiElement.SchemaItemsChildren)
                    {
                        if (ssiElementEach.Type == oldValue.ToString())
                        {
                            ssiElementEach.Type = newValue.ToString();
                        }
                        foreach (SeSchemaItem ssiElementEach2 in ssiElementEach.SchemaItemsChildren)
                        {
                            if (ssiElementEach2.Type == oldValue.ToString())
                            {
                                ssiElementEach2.Type = newValue.ToString();
                            }
                        }
                    }
                }
            }
        }
Пример #8
0
        private void Button_Search_Click(object sender, EventArgs e)
        {
            string search = textBox_Search.Text.ToLower();

            if (comboBox_SchemaList.SelectedItem != null)
            {
                SeSchema            schemaToSearch = (SeSchema)comboBox_SchemaList.SelectedItem;
                List <SeSchemaItem> ssiList        = schemaToSearch.FindElements(search);
                listView.Clear();
                label_Ref.Text = "Результаты поиска:";
                if (ssiList.Count == 0)
                {
                    listView.Items.Add("отсутствуют!");
                }
                foreach (SeSchemaItem element in ssiList)
                {
                    listView.Items.Add(element.Name);
                    listView.Items[listView.Items.Count - 1].Tag = element;
                }
            }
            else
            {
                MessageBox.Show("Для поиска нужно открыть схемы XSD");
            }
        }
Пример #9
0
        /// <summary>
        /// Запись Annotation в новый файл XSD
        /// </summary>
        /// <param name="newschemaItem">Текущий экземпляр класса SeSchemaItem(список List(SeSchemaItem) класса SeSchemaItem</param>
        /// <param name="discriptionAnn">Новый элемент XmlSchemaAnnotation</param>
        /// <returns>Измененный элемент XmlSchemaAnnotation</returns>
        public XmlSchemaAnnotation SetAnnotation(SeSchemaItem newschemaItem)
        {
            XmlSchemaAnnotation    discriptionAnn = new XmlSchemaAnnotation();
            XmlSchemaDocumentation discriptionDoc = new XmlSchemaDocumentation();

            discriptionAnn.Items.Add(discriptionDoc);
            discriptionDoc.Markup = SeSchema.TextToNodeArray(newschemaItem.Description);
            return(discriptionAnn);
        }
Пример #10
0
        private void схемуToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (openFD_XSD.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            string        filePath = openFD_XSD.FileName;
            string        filename = openFD_XSD.SafeFileName;
            DirectoryInfo diXsd    = new DirectoryInfo(filePath);

            XmlSchemaSet           xss     = null;
            XmlSchema              xs      = null;
            XmlSchemas             schemas = null;
            ValidationEventHandler ValidationErrorHandler = null;

            treeView.Nodes.Clear();
            xss = new XmlSchemaSet();
            xss.ValidationEventHandler += ValidationErrorHandler;
            xss.XmlResolver             = new XmlUrlResolver();
            schemas = new XmlSchemas();
            try
            {
                using (var sr = new StreamReader(diXsd.FullName))
                {
                    xs = XmlSchema.Read(sr, ValidationErrorHandler);
                    xss.Add(xs);
                    schemas.Add(xs);
                }
                // MessageBox.Show("Schema " + fi.Name + " read successfully ");


                xss.Compile();
            }
            catch (Exception e1)
            {
                MessageBox.Show(e.ToString());
            }

            SeSchema        seSchema;
            List <SeSchema> seSchemaList = null;

            //treeView1.BeginUpdate();
            foreach (XmlSchema schema in xss.Schemas())
            {
                seSchema     = new SeSchema(schema);
                seSchemaList = seSchemaList ?? new List <SeSchema>();
                seSchemaList.Add(seSchema);
                seSchema.ClassToTreeView(treeView.Nodes);
            }
            //treeView1.EndUpdate();
            ComboBoxBind(seSchemaList);
            BtnToTV.Enabled        = true;
            button_Refresh.Enabled = true;
            Button_Remove.Enabled  = true;
        }
Пример #11
0
 public void UpdateTreeView(TreeNodeCollection tnc)
 {
     //treeView1.BeginUpdate();
     treeView.Nodes.Clear();
     for (int i = 0; i < comboBox_SchemaList.Items.Count; i++)
     {
         SeSchema seSchema = (SeSchema)comboBox_SchemaList.Items[i];
         seSchema.ClassToTreeView(treeView.Nodes);
     }
     //treeView1.EndUpdate();
 }
Пример #12
0
        private void BtnToTV_Click(object sender, EventArgs e)
        {
            SeSchema seSchema = (SeSchema)comboBox_SchemaList.SelectedItem;

            treeView.Nodes.Clear();

            if (seSchema != null)
            {
                seSchema.ClassToTreeView(treeView.Nodes);
            }
        }
Пример #13
0
        private void Button_AddSchema_Click(object sender, EventArgs e)
        {
            SeSchema newSchema = new SeSchema();

            newSchema.ClassToTreeView(treeView.Nodes);
            UpdateComboBox();

            BtnToTV.Enabled        = true;
            button_Refresh.Enabled = true;
            Button_Remove.Enabled  = true;
        }
Пример #14
0
        private void проверитьXMLФайлToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (openFD_XML.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            string filePath = Path.GetFileName(openFD_XML.FileName);

            // читаем файл в строку
            try
            {
                XmlReaderSettings      xsdSetting             = new XmlReaderSettings();
                XmlSchema              xs                     = new XmlSchema();
                SeSchema               seSchema               = null;
                XmlSchemaSet           xss                    = new XmlSchemaSet();
                ValidationEventHandler ValidationErrorHandler = null;
                xss.ValidationEventHandler += ValidationErrorHandler;
                xss.XmlResolver             = new XmlUrlResolver();
                if ((treeView.SelectedNode != null) && (treeView.SelectedNode.Tag is SeSchema))
                {
                    seSchema = (SeSchema)treeView.SelectedNode.Tag;
                }
                else
                {
                    seSchema = (SeSchema)comboBox_SchemaList.SelectedItem;
                }
                seSchema.SaveXSD(xs);
                xss.Add(xs);
                //для записи в readonly ElementSchemaType
                try
                {
                    xss.Compile();
                }
                catch (Exception em)
                {
                    MessageBox.Show(em.ToString());
                }
                XDocument doc = XDocument.Load(openFD_XML.FileName);
                string    msg = "";
                doc.Validate(xss, (o, e1) =>
                {
                    msg += "\n - " + e1.Message + Environment.NewLine;
                }
                             );
                MessageBox.Show(msg == "" ? $"Документ { filePath} успешно прошел проверку по схеме {seSchema.Name}" : $"Документ { filePath} НЕ прошел проверку: \n" + msg);
            }
            catch {
                MessageBox.Show("Проверка невозможна");
            }
        }
Пример #15
0
 public void UpdateNode()
 {
     //treeView1.BeginUpdate();
     if (treeView.SelectedNode.Tag is SeSchemaItem)
     {
         SeSchemaItem ssi = (SeSchemaItem)treeView.SelectedNode.Tag;
         treeView.SelectedNode.Text = ssi.ToString();
     }
     else if (treeView.SelectedNode.Tag is SeSchema)
     {
         SeSchema ss = (SeSchema)treeView.SelectedNode.Tag;
         treeView.SelectedNode.Text = ss.ToString();
     }
     //treeView1.EndUpdate();
 }
Пример #16
0
        private void сохранитьТекущуюСхемуToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFD_XSD.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            string                 path     = saveFD_XSD.FileName;
            string                 filename = Path.GetFileName(path);
            XmlSchema              xs1      = new XmlSchema();
            SeSchema               seSchema = null;
            XmlSchemaSet           xss      = new XmlSchemaSet();
            ValidationEventHandler ValidationErrorHandler = null;

            xss.ValidationEventHandler += ValidationErrorHandler;
            xss.XmlResolver             = new XmlUrlResolver();
            if ((treeView.SelectedNode != null) && (treeView.SelectedNode.Tag is SeSchema))
            {
                seSchema = (SeSchema)treeView.SelectedNode.Tag;
            }
            else
            {
                seSchema = (SeSchema)comboBox_SchemaList.SelectedItem;
            }
            seSchema.SaveXSD(xs1);
            xss.Add(xs1);
            //для записи в readonly ElementSchemaType
            try
            {
                xss.Compile();
            }
            catch (Exception em)
            {
                MessageBox.Show(em.ToString());
            }
            using (FileStream fs = new FileStream(filename + ".xsd", FileMode.Create, FileAccess.ReadWrite))
            {
                using (XmlTextWriter tw = new XmlTextWriter(fs, new UTF8Encoding()))
                {
                    tw.Formatting = Formatting.Indented;
                    xs1.Write(tw);
                }
                fs.Close();
            }

            MessageBox.Show($"Файл {filename}.xsd успешно сохранен");
        }
Пример #17
0
        /// <summary>
        /// Поиск элемента, ComplexType которого - текущий элемент
        /// </summary>
        /// <returns>Список элементов с искомым ComplexType</returns>
        public SeSchemaItem FindElementOfType()
        {
            SeSchemaItem elementOfType = null;
            SeSchema     first         = GetSchema(this);

            foreach (SeSchemaItem ssiElement in first.SchemaItems)
            {
                if (ssiElement.Type == Name)
                {
                    elementOfType = ssiElement;
                }
                if (ssiElement.SchemaItemsChildren.Count != 0)
                {
                    try
                    {
                        foreach (SeSchemaItem ssiElementChild in ssiElement.SchemaItemsChildren)
                        {
                            if (ssiElementChild.Type == Name)
                            {
                                elementOfType = ssiElementChild;
                            }

                            if (ssiElementChild.SchemaItemsChildren.Count != 0)
                            {
                                foreach (SeSchemaItem ssiElementInChild in ssiElementChild.SchemaItemsChildren)
                                {
                                    if (ssiElementInChild.Type == Name)
                                    {
                                        elementOfType = ssiElementInChild;
                                    }
                                }
                            }
                        }
                    }
                    catch { }
                }
            }
            return(elementOfType);
        }
Пример #18
0
        private void выгрузитьВWordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (saveFD_DOCX.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }
            // получаем выбранный файл
            SeSchema seSchema = (SeSchema)comboBox_SchemaList.SelectedItem;

            string path           = saveFD_DOCX.FileName;
            DocX   doc            = DocX.Create(path);
            var    titleParagraph = doc.InsertParagraph();

            titleParagraph.Append(seSchema.ToString());
            titleParagraph.Bold();
            var infoParagraph = doc.InsertParagraph();

            infoParagraph.Append($"Данная схема имеет подтаблиц - {seSchema.SchemaItems.Count - 1}");//!!!

            var emptyParagraph = doc.InsertParagraph();

            emptyParagraph.Append(" ");

            foreach (SeSchemaItem si in seSchema.SchemaItems)
            {
                foreach (SeSchemaItem sic in si.SchemaItemsChildren)
                {
                    int i = 1;
                    var tableInfoParagraph = doc.InsertParagraph();

                    tableInfoParagraph.Append(si.ToString() + ":");
                    tableInfoParagraph.Bold();
                    emptyParagraph.Append(" ");

                    foreach (SeSchemaItem sicchild in sic.SchemaItemsChildren)
                    {
                        if (sic.SchemaItemsChildren.Count > 0)
                        {
                            var tableParagraph = doc.InsertParagraph();
                            if (sicchild.CheckToCommonTypes() != true)
                            {
                                tableParagraph.Append($"{i}. {sicchild.ToString()}: (данные таблицы {sicchild.Type})");
                            }
                            else
                            {
                                tableParagraph.Append($"{i}. {sicchild.ToString()}:______________________________");
                            }
                            i++;
                        }
                        var emptyParagraph1 = doc.InsertParagraph();
                        emptyParagraph1.Append(" ");
                    }
                    var emptyParagraph2 = doc.InsertParagraph();
                    emptyParagraph2.Append(" ");
                }
            }

            doc.Save();
            string filename = Path.GetFileName(path);

            MessageBox.Show($"Файл {filename}.docx успешно сохранен");
        }