Function EvaluateelementID cost Rate Attribute Name cost Resource
Пример работы с классификаторами Расчет суммы значений двух атрибутов элемента классификатора Function Evaluate(element_ID) 'Данные классификатора "Оргструктура" cost. Rate. Attribute. Name="Стоимостная ставка в час" cost. Resource. Workplace. Attribute. Name="Стоимость ресурсов в час" 'Выполнение вычислений set element = document. Item. By. ID(element_ID) r 1=element. Attribute. Value. Double(cost. Rate. Attribute. Name) r 2=element. Attribute. Value. Double(cost. Resource. Workplace. Attribute. Name) if (r 1>=0) and (r 2>=0) then result=r 1+r 2 end if if (r 1=-1. 2345678 E 9) then result=r 2 end if if (r 2=-1. 2345678 E 9) then result=r 1 end if if (r 1=-1. 2345678 E 9) and (r 2=-1. 2345678 E 9) then result=-1. 2345678 E 9 end if 'или (r 1<0) and (r 2<0) Evaluate=result End Function 46 Бизнес-инженер
Пример работы с классификаторами Расчет суммы значений атрибутов дочерних элементов классификатора 1 -го уровня Function Evaluate(element_ID) 'Данные классификатора "Процессы" element. Attribute. Name="Временные трудозатраты процесса, часов" 'Выполнение вычислений set element = document. Item. By. ID(element_ID) child. Count = element. Child. Count result=0 count=0 for i=0 to child. Count-1 r 1=element. Childs(i). Attribute. Value. Double(element. Attribute. Name) if (r 1>=0) then result=result+r 1 count=count+1 end if next if (count=0) then result=-1. 2345678 E 9 end if Evaluate=result End Function 48 Бизнес-инженер
Пример работы с классификаторами Расчет суммы значений атрибутов дочерних элементов классификатора до 5 -го уровня (включительно) Function Evaluate(element_ID) 'Данные классификатора "Процессы" element. Attribute. Name="Временные трудозатраты процесса, часов" 'Выполнение вычислений set element = document. Item. By. ID(element_ID) set child = element. First. Child(5, "") result=0 count=0 test=true do while test r 1=child. Attribute. Value. Double(element. Attribute. Name) if (r 1>=0) then result=result+r 1 count=count+1 end if set child = element. Next. Child on error resume next child_ID = child. This. ID if (Err. Number<>0) then test=false end if on error goto 0 loop if (count=0) then result=-1. 2345678 E 9 end if Evaluate=result End Function 49 Бизнес-инженер
Пример работы с классификаторами Определение нумерации и названия родительского элемента Function Evaluate(element_ID) set element = document. Item. By. ID(element_ID) parent_ID = element. Parent. ID parent. Numeration = document. Numeration(parent_ID, 0) set parent = document. item. By. ID(parent_ID) parent. Name = parent. Item. Name result = "Родительский элемент: " result = result + parent. Numeration + parent. Name Evaluate = result End Function 50 Бизнес-инженер
Пример работы с матрицами Расчет суммы произведений значений атрибутов матрицы и связанных элементов классификаторов для выбранного элемента классификатора Function Evaluate(element 1_ID) 'Данные матрицы "Процессы <> Оргструктура" matrix_GUID="{5 CC 981 B 9 -1 A 3 C-F 1 E 4 -272 B-96 CB 58 B 489 A 5}" matrix. Attribute. Name="Количество требуемых оргединиц" 'Данные классификатора "Оргструктура" cost. Work. Place. Attribute. Name="Стоимость рабочего места в час" 'Выполнение вычислений set matrix = document. Item. By. GUID(matrix_GUID) cell. Count=matrix. Matrix. Cell. Count(element 1_ID) result=0 count=0 for i=0 to cell. Count-1 element 2_ID=matrix. Matrix. Second. Classificator. ID(element 1_ID, i) r 1=matrix. Matrix. Attribute. Value. Double(element 1_ID, element 2_ID, matrix. Attribute. Name) r 2=document. item. By. ID(element 2_ID). Attribute. Value. Double(cost. Work. Place. Attribute. Name) if (r 1>=0) and (r 2>=0) then result=result+r 1*r 2 count=count+1 end if next if (count=0) then result=-1. 2345678 E 9 end if Evaluate=result End Function 52 Бизнес-инженер
Пример работы с матрицами Расчет значения атрибута ячейки матрицы на основе составляющих ее классификаторов и других атрибутов матрицы Function Evaluate(cell. ID, first. ID, second. ID) 'Данные классификатора "Процессы" process. GUID="{8 CE 93 A 56 -F 6 B 2 -C 54 B-F 172 -4 E 5 FBD 709 A 5 A}" time. Process. Attribute. Name="Время выполнения процесса, минут" amount. Performance. Process. Attribute. Name="Количество выполнений процесса" 'Данные классификатора "Оргструктура" cost. Work. Place. Attribute. Name="Стоимость рабочего места в час" 'Данные матрицы "Процессы <> Оргструктура" attribute. Name 1="Количество требуемых оргединиц" attribute. Name 2="Степень участия в процессе" 'Выполнение вычислений r 1=document. Item. By. ID(cell. ID). Matrix. Attribute. Value. Double(first. ID, second. ID, attribute. Name 1) r 2=document. Item. By. ID(cell. ID). Matrix. Attribute. Value. Double(first. ID, second. ID, attribute. Name 2) test 1=document. Item. By. GUID(process. GUID). Is. Parent. Self(first. ID) test 2=document. Item. By. GUID(process. GUID). Is. Parent. Self(second. ID) if test 1 then process. ID=first. ID org. ID=second. ID end if if test 2 then process. ID=second. ID org. ID=first. ID end if r 3=document. Item. By. ID(process. ID). Attribute. Value. Double(time. Process. Attribute. Name) r 4=document. Item. By. ID(process. ID). Attribute. Value. Double(amount. Performance. Process. Attribute. Name) r 5=document. Item. By. ID(org. ID). Attribute. Value. Double(cost. Work. Place. Attribute. Name) if (r 1>=0) and (r 2>=0) and (r 3>=0) and (r 4>=0) and (r 5>=0) then result=r 1*r 2*r 3*r 4*r 5/60 else result=-1. 2345678 E 9 end if Evaluate=result End Function 53 Бизнес-инженер
Пример работы с типами данных Определение названия типа элемента комплексного классификатора по его идентификатору Function Evaluate(element_ID) set element = document. Item. By. Id(element_ID) custom. Type_ID = custom_ID = element. Custom. Type element. Custom. ID if (custom. Type_ID>0) and (custom_ID>0) then set custom. Type = document. Item. By. ID(custom. Type_ID) custom. Name = custom. Type. Data. Type. Mgr. Get. Custom. String(custom_ID) end if if (custom. Name<>"") then result = "Тип данных: " + custom. Name end if Evaluate = result End Function 55 Бизнес-инженер
7. Формирование отчетов по Выводклассификаторам в отчет нумерации и названий дочерних элементов и матрицам классификатора до 2 -го уровня (включительно) Function Report(element_ID) set element = document. Item. By. ID(element_ID) set child = element. First. Child(2, "") result="<table border='1'>" test=true do while test child_ID=child. This. ID child. Numeration=document. numeration(child_ID, 0) child. Name=child. Item. Name result=result+"<tr><td>"+child. Numeration+"</td>" result=result+"<td>"+child. Name+"</td></tr>" set child=element. Next. Child on error resume next n=child. This. ID if (Err. Number<>0) then test=false end if on error goto 0 loop Report=result+"</table>" End Function 56 Бизнес-инженер
Пример формирования отчетов по классификатору Вывод в отчет нумерации и названий всех дочерних элементов классификатора в виде иерархического списка с помощью использования рекурсивной функции Function Report(element_ID) max. Level=-1 ' Задание количества иерархических уровней выводимых, ' подэлементов. Значение -1 выводит все уровни. level. Number=1 result=Child. Data. For. Report(element_ID, level. Number, max. Level) Report=result End Function Child. Data. For. Report(element_ID, level. Number, max. Level) set element=document. Item. By. ID(element_ID) child. Count=element. Child. Count if (child. Count>0) and ((level. Number<=max. Level) or (max. Level<0)) then result=result+"<ul style='margin-left: 30 px; '>" for i=0 to child. Count-1 set child=element. Childs(i) child_ID=child. This. ID child. Numeration=document. Numeration(child_ID, 0)+" " child. Name=child. Item. Name result=result+"<p>"+child. Numeration+child. Name+"</p>" result=result+Child. Data. For. Report(child_ID, level. Number+1, max. Level) next result=result+"</ul>" end if Child. Data. For. Report=result 58 Бизнес-инженер End function
Пример формирования отчетов по матрице Вывод в отчет нумерации и названий элементов классификаторов, связанных через матрицу с выбранным элементом классификатора Function Report(element 1_ID) 'Данные матрицы "Процессы <> Оргструктура" matrix. GUID="{5 CC 981 B 9 -1 A 3 C-F 1 E 4 -272 B-96 CB 58 B 489 A 5}" matrix. Attribute. Name="Роль в процессе" matrix. Attribute. Value="Ответственный за процесс" 'Формирование данных для вывода в отчет result="<table border='1'>" set matrix = document. Item. By. GUID(matrix. GUID). Matrix cell. Count=matrix. Cell. Count(element 1_ID) for i=0 to cell. Count-1 element 2_ID=matrix. Second. Classificator. ID(element 1_ID, i) s. Role=matrix. Attribute. Value. String(element 1_ID, element 2_ID, matrix. Attribute. Name) if (s. Role=matrix. Attribute. Value) then set element 2=document. Item. By. ID(element 2_ID) element 2 Numeration=document. numeration(element 2_ID, 0) element 2 Name=element 2. Item. Name result=result+"<tr><td>"+element 2 Numeration+"</td>" result=result+"<td>"+element 2 Name+" ("+s. Role+")"+"</td></tr>" end if next Report=result+"</table>" End Function 60 Бизнес-инженер
Пример работы с графическими диаграммами Перестановка двух фигур на графической диаграмме Function Visio. Script(visio. Control) set shapes shape. Count = visio. Control. Document. Pages(1). Shapes = shapes. Count if (shape. Count<>2) then Exit Function end if set shape 1 = shapes(1) set shape 2 = shapes(2) x 1=shape 1. Cells("Pin. X"). Result("") x 2=shape 2. Cells("Pin. X"). Result("") shape 1. Cells("Pin. X"). Result("")=x 2 shape 2. Cells("Pin. X"). Result("")=x 1 y 1=shape 1. Cells("Pin. Y"). Result("") y 2=shape 2. Cells("Pin. Y"). Result("") shape 1. Cells("Pin. Y"). Result("")=y 2 shape 2. Cells("Pin. Y"). Result("")=y 1 End Function 70 Бизнес-инженер
Пример работы с графическими диаграммами Семантическая проверка «Определение несвязанных стрелок на диаграмме» - изменяет цвет и толщину стрелок, несвязанных своими началом или окончанием с другими фигурами Function Visio. Script(visio. Control) set shapes=visio. Control. Document. Pages(1). Shapes for i=1 to shapes. Count set shape=shapes(i) if (shape. Cell. Exists("Begin. X", 0)) then formula. Begin. X = shape. Cells("Begin. X"). Formula formula. End. X = shape. Cells("End. X"). Formula test. Begin 1 = (In. Str(1, formula. Begin. X, "PAR(PNT", 1)=0) test. Begin 2 = (In. Str(1, formula. Begin. X, "_WALKGLUE", 1)=0) test. Begin = (test. Begin 1 and test. Begin 2) test. End 1 = (In. Str(1, formula. End. X, "PAR(PNT", 1)=0) test. End 2 = (In. Str(1, formula. End. X, "_WALKGLUE", 1)=0) test. End = (test. End 1 and test. End 2) if (test. Begin or test. End) then shape. Cells("Line. Weight"). Result. Force("pt") = 1. 5 shape. Cells("Line. Color"). Formula. Force. U = "RGB(255, 0, 0)" else shape. Cells("Line. Weight"). Result. Force("pt") = 0. 24 shape. Cells("Line. Color"). Formula. Force. U = "RGB(0, 0, 0)" end if next 73 Бизнес-инженер
Пример работы с графическими диаграммами Семантическая проверка «Определение несвязанных стрелок на диаграмме» - изменяет цвет и толщину стрелок, несвязанных своими началом или окончанием с другими фигурами Function Visio. Script(visio. Control) set shapes=visio. Control. Document. Pages(1). Shapes for i=1 to shapes. Count set shape = shapes(i) if (shape. Cell. Exists("Begin. X", 0)) then shape. Visio. ID = diagram. Shape. ID(i-1) position. Begin = diagram. Begin. Arrow. Position(shape. Visio. ID) position. End = diagram. End. Arrow. Position(shape. Visio. ID) if ((position. Begin<0) or (position. End<0)) then shape. Cells("Line. Weight"). Result. Force("pt") = shape. Cells("Line. Color"). Formula. Force. U = else shape. Cells("Line. Weight"). Result. Force("pt") = shape. Cells("Line. Color"). Formula. Force. U = end if 1. 5 "RGB(255, 0, 0)" 0. 24 "RGB(0, 0, 0)" end if next End Function 78 Бизнес-инженер
Пример формирования отчетов по Вывод в отчет элементов графической диаграммы процесса графической диаграмме с указанием предшествующих и последующих элементов Function Report(element_ID) 'Задание параметров connect. Name="Work. Flow. BETEC" 'Задание имени мастера фигуры связи table. Tag="width='50%' border='1' bordercolor='#000000' cellpadding='5' cellspacing='0'" table. Tag=Table. Tag+" style='border-collapse: collapse; font-family: Arial; font-size: 10 pt; color: #000000; '" 'Формирование данных для отчета set shapes=document. item. By. ID(element_ID). Node. Visio. Object shape. Count=shapes. Shape. Count 'Определение количества фигур result="<table "+table. Tag+"><tr bgcolor='E 6 E 6 E 6' style='text-align: center; font-weight: bold; '>" result=result+"<td>№</td><td>Событие/Процесс</td><td>Предшествующий элемент</td><td>Последующий элемент</td></tr>" for i=0 to shape. Count-1 'i – общий индекс фигуры s=shapes. Master. Name(i) 'Определение имени мастера фигуры if (In. Str(1, s, connect. Name, 1)<>1) then in. Connect. Count=shapes. In. Connects. Count(i) 'Определение количества входящих связей фигуры out. Connect. Count=shapes. Out. Connects. Count(i) 'Определение количества выходящих связей фигуры result=result+"<tr valign='top'><td align='center'>" result=result+Cstr(i+1)+". </td><td>"+shapes. Shape. Text(i)+"</td><td>" for j=0 to in. Connect. Count-1 source. Shape. Index=shapes. Connected. In. Shape. Index(i, j) 'Определение общего индекса фигуры-поставщика для входящей связи result=result+shapes. Shape. Text(source. Shape. Index)+" " next result=result+"</td><td>" for j=0 to out. Connect. Count-1 target. Shape. Index=shapes. Connected. Out. Shape. Index(i, j) 'Определение общего индекса фигурыпотребителя для выходящей связи result=result+shapes. Shape. Text(target. Shape. Index)+" " next result=result+"</td></tr>" end if next Report=result+"</table>" End Function 80 Бизнес-инженер
Пример формирования отчетов по Вывод в отчет элементов графической диаграммы процесса графической диаграмме с указанием входов, выходов, поставщиков и потребителей Function Report(element_ID) 'Задание параметров connect. Name="Object. Flow. BETEC" 'Задание имени мастера фигуры связи table. Tag="width='80%' border='1' bordercolor='#000000' cellpadding='5' cellspacing='0'" table. Tag=Table. Tag+" style='border-collapse: collapse; font-family: Arial; font-size: 10 pt; color: #000000; '" 'Формирование данных для отчета set shapes=document. Item. By. ID(element_ID). Node. Visio. Object shape. Count=shapes. Shape. Count 'Определение количества фигур result="<table "+table. Tag+"><tr bgcolor='E 6 E 6 E 6' style='text-align: center; font-weight: bold; '>" result=result+"<td>№</td><td>Процесс</td><td>Поставщик</td><td>Вход</td><td>Выход</td><td>Потребитель</td></tr>" for i=0 to shape. Count-1 'i – общий индекс фигуры s=shapes. Master. Name(i) 'Определение имени мастера фигуры if (In. Str(1, s, connect. Name, 1)<>1) then in. Connect. Count=shapes. In. Connects. Count(i) 'Определение количества входящих связей фигуры out. Connect. Count=shapes. Out. Connects. Count(i) 'Определение количества выходящих связей фигуры result=result+"<tr valign='top'><td align='center'>" result=result+Cstr(i+1)+". </td><td>"+shapes. Shape. Text(i)+"</td><td>" for j=0 to in. Connect. Count-1 source. Shape. Index=shapes. Connected. In. Shape. Index(i, j) 'Определение общего индекса фигуры-поставщика для входящей связи result=result+shapes. Shape. Text(source. Shape. Index)+" " next result=result+"</td><td>" for j=0 to in. Connect. Count-1 in. Connect. Index=shapes. Connected. In. Arrow. Index(i, j) 'Определение общего индекса входящей связи result=result+shapes. Shape. Text(in. Connect. Index)+" " next result=result+"</td><td>" for j=0 to out. Connect. Count-1 out. Connect. Index=shapes. Connected. Out. Arrow. Index(i, j) 'Определение общего индекса выходящей связи result=result+shapes. Shape. Text(out. Connect. Index)+" " next result=result+"</td><td>" for j=0 to out. Connect. Count-1 target. Shape. Index=shapes. Connected. Out. Shape. Index(i, j) 'Определение общего индекса фигуры-потребителя для выходящей связи result=result+shapes. Shape. Text(target. Shape. Index)+" " next result=result+"</td></tr>" end if next Report=result+"</table>" End Function 83 Бизнес-инженер
10. Вызов методов внешних СОМ-серверов Пример создания файла на диске, вывод в него данных и открытие файла Function output. Data. File(output. Data) set my. FSO = Create. Object("Scripting. File. System. Object") set write. Result = my. FSO. Create. Text. File("C: /Выполнение KPI. htm", true) write. Result. write. Line(output. Data) write. Result. Close set my. FSO = nothing set obj. Shell = Create. Object("Shell. Application") obj. Shell. Execute "C: /Выполнение KPI. htm", "", "", 1 set obj. Shell = nothing End Function 86 Бизнес-инженер
Работа с файлами на диске Пример работы с файлами на диске ' Listing 1. Code to Change Only One File Attribute Const Read. Only = 1 Set fso = Create. Object("Scripting. File. System. Object") Set file = fso. Get. File("C: foo. txt") If file. Attributes And Read. Only Then file. Attributes = file. Attributes And (Not Read. Only) Else file. Attributes = file. Attributes Or Read. Only End If ' Listing 2. The Rename. File Function Rename. File(old. Name, new. Name) Set fso = Create. Object("Scripting. File. System. Object") Set file = fso. Get. File(old. Name) file. Name = new. Name End Function 92 Бизнес-инженер
Пример работы с файлами на диске (продолжение) ' Listing 3. Script Using FSO Objects to Obtain a Directory Listing Const Archive = 0 Const Read. Only = 1 Const Hidden = 2 Const System = 4 folder. Name = "C: « ' Gets the collection of files. Set fso = Create. Object("Scripting. File. System. Object") Set files = fso. Get. Folder(folder. Name). Files ' Loops through the list of files. str = "" For Each f In files str = str & f. Name & vb. Tab & f. Size _ & vb. Tab & Format. Attrib(f. Attributes) str = str & vb. Cr. Lf Next Msg. Box str Function Format. Attrib(attr) Dim str = "" If attr And Archive Then str = str & "Archive, " If attr And Read. Only Then str = str & "Readonly, " If attr And Hidden Then str = str & "Hidden, " If attr And System Then str = str & "System, " str = str & "Normal" Format. Attrib = str End Function 93 Бизнес-инженер
- Slides: 93