コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: SashaKoragin/My
 public void TestLoadTemplate()
 {
     ServiceRest      rest             = new ServiceRest();
     var              xml              = new LibaryXMLAuto.ReadOrWrite.XmlReadOrWrite();
     InfoRuleTemplate infoRuleTemplate = (InfoRuleTemplate)xml.ReadXml("D:\\InfoRuleTemplate.xml", typeof(InfoRuleTemplate));
     var              t = rest.LoadInfoTemplateToDataBase(infoRuleTemplate);
 }
コード例 #2
0
 /// <summary>
 /// Сохранение отчета по Информации о ролях и ветках
 /// </summary>
 /// <param name="pathReport">Путь сохранения файла с информацией о ролями</param>
 /// <param name="infoRuleTemplate">Шаблон Подсистем</param>
 public static void CreateFileInfoRuleTemplate(string pathReport, InfoRuleTemplate infoRuleTemplate)
 {
     if (File.Exists(pathReport))
     {
         XmlReadOrWrite read = new XmlReadOrWrite();
         read.AddInfoRuleTemplate(pathReport, infoRuleTemplate);
     }
     else
     {
         var convert = new Converts.ConvettToXml.XmlConvert();
         convert.SerializerClassToXml(pathReport, infoRuleTemplate, typeof(InfoRuleTemplate));
     }
 }
コード例 #3
0
ファイル: XmlReadOrWrite.cs プロジェクト: SashaKoragin/WPFLib
        /// <summary>
        /// Метод добавление в файл Шаблонов ролей в отчет
        /// </summary>
        /// <param name="path">Путь сохранения</param>
        /// <param name="infoRuleTemplate">Шаблон ролей</param>
        public void AddInfoRuleTemplate(string path, InfoRuleTemplate infoRuleTemplate)
        {
            var        doc      = LogicaXml.LogicaXml.Document(path);
            XmlElement xRoot    = doc.DocumentElement;
            XmlElement infoRule = doc.CreateElement("SystemAis");

            foreach (var systemAis in infoRuleTemplate.SystemAis)
            {
                infoRule.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Name", systemAis.Name));
                foreach (var systemAisFolder in systemAis.Folders)
                {
                    var folder = doc.CreateElement("Folders");
                    folder.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Name", systemAisFolder.Name));
                    infoRule.AppendChild(folder);
                    foreach (var tasks in systemAisFolder.Tasks)
                    {
                        var task = doc.CreateElement("Tasks");
                        task.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Name", tasks.Name));
                        task.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Curator", tasks.Curator));
                        task.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "TypeTask", tasks.TypeTask));
                        folder.AppendChild(task);
                        foreach (var rolesTemplates in tasks.RolesTemplate)
                        {
                            var rolesTemplate = doc.CreateElement("RolesTemplate");
                            rolesTemplate.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Name", rolesTemplates.Name));
                            task.AppendChild(rolesTemplate);
                            foreach (var templates in rolesTemplates.Templates)
                            {
                                var template = doc.CreateElement("Templates");
                                template.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Name", templates.Name));
                                template.Attributes.Append(CreateElement.CreteElement.AtributeAddString(doc, "Category", templates.Category));
                                rolesTemplate.AppendChild(template);
                            }
                        }
                    }
                }
                xRoot.AppendChild(infoRule);
            }
            doc.Save(path);
        }
コード例 #4
0
ファイル: ServiceRest.cs プロジェクト: SashaKoragin/My
        /// <summary>
        /// Загрузка шаблонов в БД
        /// </summary>
        /// <param name="infoTemplate">Шаблоны</param>
        /// <returns></returns>
        public ModelPathReport LoadInfoTemplateToDataBase(InfoRuleTemplate infoTemplate)
        {
            var sql = new SelectSql();

            return(sql.LoadModelToDataBase(infoTemplate, 36, 2));
        }
コード例 #5
0
        /// <summary>
        /// Сбор информации о шаблонах папках и ветках и ролях по ветке modelTree
        /// </summary>
        /// <param name="statusButton">Кнопка запуска</param>
        /// <param name="pathJournalInfoRule">Путь сохранения информации</param>
        public void SelectAllTemplateAndRule(StatusButtonMethod statusButton, string pathJournalInfoRule)
        {
            var rowNumber = 1;
            var sw        = modelTreeMyRule.Split('\\').Last();
            var fullTree  = string.Concat(PublicElementName.FullTree, $"Name:{sw}");
            LibraryAutomations libraryAutomation = new LibraryAutomations(WindowsAis3.AisNalog3);

            if (!libraryAutomation.IsEnableExpandTree(modelTreeMyRule))
            {
                return;
            }
            libraryAutomation.FindFirstElement(fullTree, null, true);
            libraryAutomation.FindElement.SetFocus();
            libraryAutomation.ClickElements(fullTree, null, false, 25, 0, 0, 2);
            PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, ItElementName.ApplicationTab);
            PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, ItElementName.ButtonAdd);
            PublicGlobalFunction.PublicGlobalFunction.WindowElementClick(libraryAutomation, ItElementName.AutoInfo);
            libraryAutomation.IsEnableElement(ItElementName.GridRule);

            if (File.Exists(pathJournalInfoRule))
            {
                var readFileInfoRule     = new LibaryXMLAuto.ReadOrWrite.XmlReadOrWrite();
                var fileInfoRuleTemplate = (InfoRuleTemplate)readFileInfoRule.ReadXml(pathJournalInfoRule, typeof(InfoRuleTemplate));
                var nameAttributes       = fileInfoRuleTemplate.SystemAis.Last().Name;
                var index = 0;
                var stop  = false;
                libraryAutomation.SelectAutomationColrction(libraryAutomation.FindElement).Cast <AutomationElement>()
                .Where(elem => elem.Current.Name.Contains("List`"))
                .ToList().ForEach(element =>
                {
                    if (stop)
                    {
                        return;
                    }
                    else
                    {
                        if (libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(libraryAutomation.SelectAutomationColrction(element)
                                                                                              .Cast <AutomationElement>()
                                                                                              .First(elem => elem.Current.Name.Contains("Подсистема"))) == nameAttributes)
                        {
                            rowNumber = index;
                            rowNumber++;
                            stop = true;
                        }
                        index++;
                    }
                });
            }

            AutomationElement automationElementRow;

            while ((automationElementRow = libraryAutomation.IsEnableElements(string.Format(ItElementName.ListRow, rowNumber), null, true, 30)) != null)
            {
                if (statusButton.Iswork)
                {
                    var infoRuleTemplate = new InfoRuleTemplate()
                    {
                        SystemAis = new SystemAis[1]
                    };
                    automationElementRow.SetFocus();
                    SendKeys.SendWait(ButtonConstant.Plus);
                    infoRuleTemplate.SystemAis[0] = new SystemAis()
                    {
                        Name = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                            libraryAutomation.SelectAutomationColrction(automationElementRow).Cast <AutomationElement>()
                            .First(elem => elem.Current.Name.Contains("Подсистема")))
                    };

                    var foldersNumber = 1;
                    var listFolder    = libraryAutomation
                                        .SelectAutomationColrction(automationElementRow).Cast <AutomationElement>()
                                        .Where(elem => elem.Current.Name.Contains("Folders row"));
                    infoRuleTemplate.SystemAis[0].Folders = new Folders[listFolder.Count()];

                    AutomationElement automationElementFolder;
                    while ((automationElementFolder = libraryAutomation.IsEnableElements(string.Format(ItElementName.ListFolders, rowNumber, foldersNumber), null, true, 30)) != null)
                    {
                        automationElementFolder.SetFocus();
                        SendKeys.SendWait(ButtonConstant.Plus);

                        infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1] = new Folders()
                        {
                            Name = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                libraryAutomation.SelectAutomationColrction(automationElementFolder)
                                .Cast <AutomationElement>().First(elem => elem.Current.Name.Contains("Папка")))
                        };

                        var tasksNumber = 1;
                        var listTask    = libraryAutomation
                                          .SelectAutomationColrction(automationElementFolder).Cast <AutomationElement>()
                                          .Where(elem => elem.Current.Name.Contains("Tasks row"));

                        infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1].Tasks = new Tasks[listTask.Count()];

                        AutomationElement automationElementTask;
                        while ((automationElementTask = libraryAutomation.IsEnableElements(string.Format(ItElementName.ListTasks, rowNumber, foldersNumber, tasksNumber), null, true, 1)) != null)
                        {
                            automationElementTask.SetFocus();
                            SendKeys.SendWait(ButtonConstant.Plus);

                            infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1].Tasks[tasksNumber - 1] = new Tasks()
                            {
                                Name = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                    libraryAutomation.SelectAutomationColrction(automationElementTask)
                                    .Cast <AutomationElement>().First(elem => elem.Current.Name.Contains("Задача"))),
                                TypeTask = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                    libraryAutomation.SelectAutomationColrction(automationElementTask)
                                    .Cast <AutomationElement>().First(elem => elem.Current.Name.Contains("Тип"))),
                                Curator = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                    libraryAutomation.SelectAutomationColrction(automationElementTask)
                                    .Cast <AutomationElement>().First(elem => elem.Current.Name.Contains("Куратор")))
                            };

                            var rolesNumber = 1;

                            var listRole = libraryAutomation
                                           .SelectAutomationColrction(automationElementTask).Cast <AutomationElement>()
                                           .Where(elem => elem.Current.Name.Contains("Roles row"));
                            infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1].Tasks[tasksNumber - 1]
                            .RolesTemplate = new RolesTemplate[listRole.Count()];


                            AutomationElement automationElementRole;
                            while ((automationElementRole = libraryAutomation.IsEnableElements(string.Format(ItElementName.ListRoles, rowNumber, foldersNumber, tasksNumber, rolesNumber), null, true, 1)) != null)
                            {
                                automationElementRole.SetFocus();
                                SendKeys.SendWait(ButtonConstant.Plus);

                                infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1].Tasks[tasksNumber - 1]
                                .RolesTemplate[rolesNumber - 1] = new RolesTemplate()
                                {
                                    Name = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                        libraryAutomation.SelectAutomationColrction(automationElementRole)
                                        .Cast <AutomationElement>().First(elem => elem.Current.Name.Contains("Роль")))
                                };
                                var taskTemplateNumber = 1;

                                var listTaskTemplate = libraryAutomation
                                                       .SelectAutomationColrction(automationElementRole).Cast <AutomationElement>()
                                                       .Where(elem => elem.Current.Name.Contains("TaskTemplates row"));
                                infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1].Tasks[tasksNumber - 1]
                                .RolesTemplate[rolesNumber - 1].Templates = new Templates[listTaskTemplate.Count()];

                                AutomationElement automationElementTaskTemplate;
                                while ((automationElementTaskTemplate = libraryAutomation.IsEnableElements(string.Format(ItElementName.ListTaskTemplates, rowNumber, foldersNumber, tasksNumber, rolesNumber, taskTemplateNumber), null, true, 1)) != null)
                                {
                                    automationElementTaskTemplate.SetFocus();

                                    infoRuleTemplate.SystemAis[0].Folders[foldersNumber - 1]
                                    .Tasks[tasksNumber - 1].RolesTemplate[rolesNumber - 1]
                                    .Templates[taskTemplateNumber - 1] = new Templates()
                                    {
                                        Name = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                            libraryAutomation.SelectAutomationColrction(automationElementTaskTemplate)
                                            .Cast <AutomationElement>()
                                            .First(elem => elem.Current.Name.Contains("Шаблон"))),
                                        Category = libraryAutomation.ParseElementLegacyIAccessiblePatternIdentifiers(
                                            libraryAutomation.SelectAutomationColrction(automationElementTaskTemplate)
                                            .Cast <AutomationElement>()
                                            .First(elem => elem.Current.Name.Contains("Категории")))
                                    };
                                    taskTemplateNumber++;
                                }
                                automationElementRole.SetFocus();
                                SendKeys.SendWait(ButtonConstant.Minus);
                                rolesNumber++;
                            }
                            automationElementTask.SetFocus();
                            SendKeys.SendWait(ButtonConstant.Minus);
                            tasksNumber++;
                        }
                        automationElementFolder.SetFocus();
                        SendKeys.SendWait(ButtonConstant.Minus);
                        foldersNumber++;
                    }
                    automationElementRow.SetFocus();
                    SendKeys.SendWait(ButtonConstant.Minus);
                    LibaryXMLAuto.ErrorJurnal.ReportMigration.CreateFileInfoRuleTemplate(pathJournalInfoRule, infoRuleTemplate);
                    rowNumber++;
                }
                else
                {
                    break;
                }
            }
        }