
Сообщение от
Pimpl
Можешь поделиться итоговым скриптом?
Получилось так:
Код:
using System;
using MasterSCADA.Script.FB;
using MasterSCADA.Hlp;
using FB;
using System.Linq;
using System.Windows.Forms;
using MasterSCADALib;
using System.IO;
using MasterSCADA.Documents;
using System.Collections.Generic;
using System.Text;
using MasterSCADA.Common;
using FB.FBAttributes;
using System.ComponentModel;
using InSAT.Library;
public partial class ФБ : ScriptBase
{
const string FilePathNameFormls = "D:\\formuls.csv"; // Файл для формул
const string FilePathNameEvnts = "D:\\events.csv"; // Файл для событий
public override void DoAction()
{
//Поиск События или Расчёта с заданными формулами
using (var file = new StreamWriter(FilePathNameFormls, false, Encoding.GetEncoding("windows-1251")))
{
//перебор всех значений данного объекта
HostFB.TreeItemHlp.Project.ObjectTreeRootItem.NavigateChilds(delegate(ITreeObjectHlp e)
{
if(e.TypeName == "Событие" || e.TypeName == "Расчет")
{
var action = e as ParserHlp;
if(action.Formula != null && (true/*Ещё какие-то условия, смторя что вы ищите*/))
{
string frm = action.Formula.Replace("\n", "");
frm = frm.Replace("\r", "");
file.WriteLine(string.Format("{0};{1}", action.FullName, frm));
}
}
return true;
}, TreeItemMask.All, NavigateItemsFlags.CurrentComputer);
}
//Поиск события с заданным текстом сообщения
using (var file = new StreamWriter(FilePathNameEvnts, false, Encoding.GetEncoding("windows-1251")))
{
//перебор всех значений данного объекта
HostFB.TreeItemHlp.Project.ObjectTreeRootItem.NavigateChilds(delegate(ITreeObjectHlp e)
{
if(e.TypeName == "Событие")
{
var action = e as EventHlp;
if(action.Pattern != null && (true/*Ещё какие-то условия, смторя что вы ищите*/))
{
string frm = action.Pattern.Replace("\n", "");
frm = frm.Replace("\r", "");
file.WriteLine(string.Format("{0};{1}", action.FullName, frm));
}
}
return true;
}, TreeItemMask.All, NavigateItemsFlags.CurrentComputer);
}
}
}